How to Install Tensorflow with Anaconda on Windows

In this blog, explore how to harness the power of TensorFlow, a versatile machine learning library, as a data scientist’s essential tool. This tutorial guides you through the seamless installation of TensorFlow using Anaconda on a Windows.

As a data scientist, one of the most important tools in your arsenal is a powerful machine learning library. Tensorflow is one such library that has gained a lot of popularity in recent years due to its ease of use and versatility. In this tutorial, we will walk you through the process of installing Tensorflow with Anaconda on Windows.

Struggling to install TensorFlow with Anaconda on Windows? Remove complex setups in Saturn Cloud with built-in tools for individuals and teams. Request a free demo to learn more..

What is Tensorflow?

Tensorflow is an open-source machine learning library developed by Google Brain Team. It was initially released in 2015 and has since become one of the most popular machine learning libraries. Tensorflow is used for a wide range of applications, including computer vision, natural language processing, and speech recognition.

What is Anaconda?

Anaconda is a popular platform used by data scientists to manage their packages and environments. It comes with a package manager called conda, which makes it easy to install, update, and remove packages. Anaconda also provides a user-friendly interface called Anaconda Navigator, which allows you to manage your packages and environments with a graphical user interface.

Step-by-Step Guide to Installing Tensorflow with Anaconda on Windows

Step 1: Install Anaconda

The first step is to download and install Anaconda on your Windows machine. You can download the latest version of Anaconda from the official website: https://www.anaconda.com/products/individual#windows. Make sure to select the appropriate version (32-bit or 64-bit) depending on your system architecture.

Step 2: Create a New Environment

Once you have installed Anaconda, the next step is to create a new environment for Tensorflow. You can use the following command to create a new environment called tensorflow:

conda create -n tensorflow python=3.8

This command will create a new environment called tensorflow with Python 3.8 installed.

Step 3: Activate the Environment

After creating the environment, you need to activate it using the following command:

conda activate tensorflow

Step 4: GPU setup (You can skip this step if you only run Tensorflow on CPU)

First you have to install the NVIDIA GPU driver if it’s not already installed

Next, use conda to install CUDA and cuDNN.

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

Step 5: Install Tensorflow

Before installing Tensorflow, make sure to upgrade your pip to the lastest version as Tensorflow requires a recent version of pip.

pip install --upgrade pip

Now that you have created and activated the environment, you can install Tensorflow using the following command:

pip install tensorflow

This command will download and install the latest version of Tensorflow in your environment.

Step 6: Verify the Installation

To verify that Tensorflow is installed correctly, you can open a Python shell and run the following commands:

Verify the CPU setup:

python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

If a tensor is returned, you’ve installed TensorFlow successfully.

Verify the GPU setup:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If the output is a list of GPUs, Tensorflow GPU is successfully installed.

Struggling to install TensorFlow with Anaconda on Windows? Remove complex setups in Saturn Cloud with built-in tools for individuals and teams. Request a free demo to learn more..

Conclusion

In this tutorial, we have walked you through the process of installing Tensorflow with Anaconda on Windows. By following these steps, you can quickly set up a new environment for Tensorflow and start building machine learning models. Tensorflow is a powerful library that can help you solve a wide range of machine learning problems, and by using Anaconda, you can manage your packages and environments with ease.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Request a demo today to learn more.