Open In App

How to Install TensorFlow in Anaconda

Last Updated : 12 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

TensorFlow is an open-source machine learning framework built by Google. Anaconda Navigator is a graphical user interface (GUI) application using which we work with packages and environments without using command line interface (CLI) commands. In this article, we will learn how to install TensorFlow in Anaconda.

What is TensorFlow?

TensorFlow is a popular open-source machine learning framework built by Google. It was built for Google’s internal use only but was later publicly released in 2015. It is used for numerical computation, large-scale machine learning, and deep learning. TensorFlow is best for machine learning because of its features like flexibility, scalability, and ease of use. We can build various models to perform image recognition, natural language processing, speech recognition, and more.

What is an Anaconda?

Anaconda Navigator is a desktop GUI application using which users can work with various packages and environments without using CLI commands. It comes with various inbuilt applications. We can launch applications, and manage condo packages, environments, and channels using it. We can also install, run, and update packages in an environment. It is usually used online to install and download packages and when the internet is not available it automatically switches to offline mode.

Steps to install TensorFlow in Anaconda

Step 1: Install Anaconda Navigator.

Step 2: After installing Anaconda in a system, we will create a new environment where we install tensorflow. We can do the same by executing the below command in a command prompt. Here we have created a new isolated environment with name “myEnv”. Whatever work we do in this environment it cannot affect the other. It is to be prefer to create a new environment before starting a new project.

conda create -n myEnv python=3.8

Step 3: To use newly created environment, we have to activate that environment first which can be done by executing below command in a command prompt.

conda activate myEnv

Step 4: For better performance we can setup GPU. First install NVIDIA GPU driver if not installed and then execute the below command in a command prompt or terminal to install CUDA and cuDNN. This step is optional if not want to use the GPU and run the ML models on CPU only.

Step 5: TensorFlow requires the latest version of pip so, first upgrade the pip to the latest version by executing below command.

pip install --upgrade pip


Now, install tensorflow in the newly created environment.

pip install tensorflow

Step 6: Now to verify the installation of TensorFlow we can execute the below command in the Python shell.

Verify the CPU setup: Verifying the CPU setup by executing the below command.

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

Verify the GPU setup: To verify the GPU setup execute the below command.

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


Now, TensorFlow is successfully install in Anaconda.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads