For Developers

Installation Guide of TensorFlow Through Pip and Conda

TensorFlow through pip and conda

TensorFlow is an end-to-end open-source platform for machine learning (ML), backed by a comprehensive yet flexible ecosystem of tools, libraries, and communities. It is that magic well that allows developers to build and deploy ML-powered applications easily. This free software library is used for a variety of tasks with a focus on the inference and training of deep neural networks. In this article, we’ll look at how to install TensorFlow through pip and conda as well as the prerequisites.

A brief on TensorFlow

Although originally developed to resolve large numerical computations, TensorFlow is primarily used for deep learning applications. It aids performance by programming the vital parts in C++ even though it uses Python. With this, there is less human thought overhead with Python and a simpler interface for experimentation can take place. From fast numerical computing to creating deep learning models, this foundation library simplifies the process built on top of TensorFlow.

The platform allows you to take new ideas from concept to code. The simple and flexible architecture enables you to build state-of-the-art models and publications faster. It offers a bundle of workflows with high-level APIs that work wonders for beginners as well as experts.

TensorFlow can help you build ML models with intuitive APIs like Keras. You can efficiently train and deploy these models on-premise, on the cloud, the browser, or on a device, irrespective of the language you use. The models can be trained using high-level APIs that make for easy debugging and immediate model iteration.

TensorFlow competes with other frameworks like Apache MXNet and PyTorch. It can also train and run deep neural networks for word embedding, sequence to sequence models for machine translation, partial differential equation-based simulations, and natural language processing. It offers greater flexibility to train your own models by allowing you to use code from the TensorFlow Model Garden.

As for the working of TensorFlow, it allows developers to create data flow graphs - structures that illustrate how data moves through a series of processing nodes or graphs. The nodes in the graph showcase a mathematical operation and each connection between the nodes is a multidimensional data array which is referred to as a tensor.

Prerequisites to install TensorFlow

Before installing TensorFlow, it’s important to check the conditions below.

What type of installation will suit your requirements the best?

Here are the following types of installations you can choose to suit your needs.

- Install TensorFlow with GPU support: Although it takes more time to install, the faster processing balances it out. Do make sure that you meet the following checklist before you install TensorFlow with GPU support.

  • CUDA Toolkit 9.0
  • NVIDIA drivers associated with CUDA Toolkit 9.0
  • cuDNN v7.0
  • GPU card (with CUDA Compute Capability 3.0 or more).

- Install TensorFlow with CPU support: It’s recommended that you use this type of installation only when you don't have an NVIDIA GPU in your system. It will also take less time than the GPU supported version.

Python without Anaconda

The steps below illustrate how to install TensorFlow without Anaconda.

Step 1: Check your Python version

See what version of Python you have by using the command:

$ python --version

Ensure that the version is Python 3.4+. You can check the same directly using the command below:

$ python3 --version

If you’re using any other Python version, install the one required for TensorFlow with this command:

$ brew update
$ brew install python # Installs Python 3
$ sudo apt install python3-dev python3-pip

Step 2: Install virtualenv

This will help you create the virtual environment required to install TensorFlow. You can do it for macOS and Ubuntu as follows:

For Ubuntu,

$ sudo pip3 install -U virtualenv# system-wide install

For macOS,

$ sudo pip3 install -U virtualenv# system-wide install

Tip: You can use pip or pip3. Use the latter if you have second thoughts. If you still want to use pip, ‌check if it’s possible.

$ pip3 --version
pip 19.1.1 from /Users/inferno/anaconda/lib/python3.6/site-packages/pip (python 3.6)
$ pip --version
pip 19.1.1 from /Users/inferno/anaconda/lib/python3.6/site-packages/pip (python 3.6)

Code source

Python 3.4+ with Anaconda

Installing Anaconda offers a simple approach to installing Python. With Anaconda, you will have conda to create a virtual environment to install the package.

Hardware requirements

TensorFlow will not be loaded on older GPUs when CUDA_FORCE_PTX_JIT=1 is set. This is because packages do not include PTX code except in the latest supported CUDA architecture.

GPU-enabled devices support NVIDIA GPU cards with CUDA architectures of 3.5, 5.0, 6.0, 7.0, 7.5, 8.0 and above.

System requirements

Here is a list of systems that support TensorFlow installation.

  • Python 3.7 to 3.10
  • Windows 7 and higher - (64-bit)
  • macOS 10.12.6 (Sierra) or higher- (64-bit)
  • Ubuntu 16.04 and higher - (64-bit)
  • Windows WSL2 Windows 10 19044 or higher - (64-bit).

Miniconda installation

You need to install Miniconda before installing TensorFlow with conda.

curl -o

Code source

Select enter and ‘yes’ during the installation. If needed, restart your terminal or source ~/.bashrc to enable the conda command. Use conda -V to check if Miniconda is installed successfully.

Now that the prerequisites have been fulfilled, let’s get started with the TensorFlow installation process.

How to install TensorFlow

installation process of TensorFlow.webp

Create a Python conda environment

We will create a virtual environment in Python where we will have a completely independent set of packages and settings. They won’t conflict with anything in the default local Python environment or other virtual environments.

Tip: Doing this will help you keep different versions of the same package. This means that you can use scikit-learn 0.22 for one project and scikit-learn 0.1 for another.

  • Python without Anaconda

For developers using Mac/Ubuntu, the command below will create a virtual environment (considering Python without Anaconda).

$ virtualenv --system-site-packages -p python3 tf_2
  • Python from Anaconda

For developers already using conda, the following command will help create the virtual environment.

$ conda create -n tf_2

Activate the virtual environment

Use the given command in your terminal to activate the virtual environment created above.

  • For Ubuntu/Mac and Python without Anaconda, use the following command:
$ source tf_2/bin/activate
  • For Ubuntu/Mac and Python from Anaconda, use:
$ conda activate tf_2

Code source

Once you activate the virtual environment, the terminal will change to (tf_2) $.

Install TensorFlow 2

The GPU and CPU are packed as a single bundle in TensorFlow 2. This means that they don’t need to be installed separately.

The following pip command will help you install the latest version of TensorFlow in the newly created conda environment above.

# Requires the latest pip
pip install --upgrade pip

# Current stable release for CPU and GPU
pip install tensorflow

Note: If you want to install the current tf-nightly build, the command below will help you do so:

pip install tf-nightly

Code source

Test the installation

Once TensorFlow is installed, check the version of the tf package.

(tf_2) $ python -c "import tensorflow as tf; x = [[2.]]; print('tensorflow version', tf.__version__);
 print('hello, {}'.format(tf.matmul(x, x)))"

You can expect the following output with successful installation:

tensorflow version 2.0.0-rc1
hello, [[4.]]

Code source

Quick install commands

Here are a few quick versions of the install commands for various systems.

1. Windows Native

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

2. Windows WSL2

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

3. CPU

python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

4. Linux

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

5. Nightly

python3 -m pip install tf-nightly
# Verify install:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

6. macOS

python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

Code source


Here’s a handy checklist to follow:

Step 1: Begin by finding if the GPU is compatible with TensorFlow GPU.

Step 2: Download and install the CUDA toolkit.

Step 3: Sign up on the NVIDIA Developer website and download cuDNN.

Step 4: Install cuDNN by extracting the contents into the toolkit path installed in step 2.

Note: Replace the files you have in the CUDA Toolkit Directory.

Step 5: Check your path variables. Look for CUDA_HOME. If it is not present, add it manually.

Step 6: Check the path variables’ presence in the toolkit paths.

Step 7: Install Miniconda or Anaconda.

Step 8: Create an environment with Python and pip packages installed.

Step 9: Install by “pip install TensorFlow-gpu” and test it.

In this article, we examined the TensorFlow installation process in detail with step-by-step instructions. Now that you’ve learned how to install it through pip and conda, you can use it for your machine learning projects.


  • Author

    Srishti Chaudhary

    Srishti is a competent content writer and marketer with expertise in niches like cloud tech, big data, web development, and digital marketing. She looks forward to grow her tech knowledge and skills.

Frequently Asked Questions

To install TensorFlow on Anaconda pip, follow these steps: Open command prompt. If you are operating only on one version of Python, type in cmd: C:/>conda install tensorflow. If you have multiple versions of Python, look for the version you want to install TensorFlow. Then, type in cmd: C:/>conda install tensorflow python=version(e.g.python=3.5).

The fundamental difference between conda and pip is what lies inside the packages. conda packages include C libraries, Python libraries, executables, and even the Python interpreter itself. On the other hand, pip packages are Python libraries like Matplotlib and NumPy.

Anaconda includes the most common packages or tools that are required by data scientists. They are essentially the hardware store of the tools required in data science. On the other hand, conda is a package manager that handles installation, updates, and removal of different packages.

View more FAQs


What's up with Turing? Get the latest news about us here.


Know more about remote work.
Checkout our blog here.


Have any questions?
We'd love to hear from you.

Hire remote developers

Tell us the skills you need and we'll find the best developer for you in days, not weeks.

Hire Developers