Missed TensorFlow World? Check out the recap. Learn more

Install TensorFlow with pip

TensorFlow 2 packages are available

  • tensorflow —Latest stable release for CPU-only
  • tensorflow-gpu —Latest stable release with GPU support (Ubuntu and Windows)
  • tf-nightly —Preview build (unstable). Ubuntu and Windows include GPU support.

Older versions of TensorFlow

For the 1.15 release, CPU and GPU support are included in a single package:

  • tensorflow==1.15 —The final 1.x release. Ubuntu and Windows include GPU support

For releases 1.14 and older, CPU and GPU packages are separate:

  • tensorflow==1.14 —Release for CPU-only
  • tensorflow-gpu==1.14 —Release with GPU support (Ubuntu and Windows)

System requirements

  • pip 19.0 or later (requires manylinux2010 support)
  • Ubuntu 16.04 or later (64-bit)
  • macOS 10.12.6 (Sierra) or later (64-bit) (no GPU support)
  • Windows 7 or later (64-bit) (Python 3 only)
  • Raspbian 9.0 or later

Hardware requirements

  • Starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
  • Read the GPU support guide to set up a CUDA®-enabled GPU card on Ubuntu or Windows.

1. Install the Python development environment on your system

Check if your Python environment is already configured:

python --version
pip --version
virtualenv --version

If these packages are already installed, skip to the next step.
Otherwise, install Python, the pip package manager, and Virtualenv:

Ubuntu

sudo apt update
sudo apt install python-dev python-pip
sudo pip install -U virtualenv  # system-wide install

mac OS

Install using the Homebrew package manager:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python@2  # Python 2
sudo pip install -U virtualenv  # system-wide install

Raspberry Pi

Requirements for the Raspbian operating system:

sudo apt update
sudo apt install python-dev python-pip
sudo apt install libatlas-base-dev     # required for numpy
sudo pip install -U virtualenv         # system-wide install

Other

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
sudo pip install -U virtualenv  # system-wide install

2. Create a virtual environment (recommended)

Python virtual environments are used to isolate package installation from the system.

Ubuntu / mac OS

Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:

virtualenv --system-site-packages -p python2.7 ./venv

Activate the virtual environment using a shell-specific command:

source ./venv/bin/activate  # sh, bash, ksh, or zsh

When virtualenv is active, your shell prompt is prefixed with (venv).

Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:

pip install --upgrade pip

pip list  # show packages installed within the virtual environment

And to exit virtualenv later:

deactivate  # don't exit until you're done using TensorFlow

Windows

Create a new virtual environment by choosing a Python interpreter and making a .\venv directory to hold it:

Activate the virtual environment:

.\venv\Scripts\activate

Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:

pip install --upgrade pip

pip list  # show packages installed within the virtual environment

And to exit virtualenv later:

deactivate  # don't exit until you're done using TensorFlow

Conda

Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:

conda create -n venv pip python=2.7

Activate the virtual environment:

source activate venv

Within the virtual environment, install the TensorFlow pip package using its complete URL:

pip install --ignore-installed --upgrade packageURL

And to exit virtualenv later:

source deactivate

3. Install the TensorFlow pip package

Choose one of the following TensorFlow packages to install from PyPI:

  • tensorflow —Latest stable release (2.x) for CPU-only (recommended for beginners).
  • tensorflow-gpu —Latest stable release with GPU support (Ubuntu and Windows).
  • tf-nightly —Preview build (unstable). Ubuntu and Windows include GPU support.
  • tensorflow==1.15 —The final version of TensorFlow 1.x.

Virtualenv install

pip install --upgrade tensorflow

Verify the install:

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

System install

pip install --user --upgrade tensorflow  # install in $HOME

Verify the install:

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

Package location

A few installation mechanisms require the URL of the TensorFlow Python package. The value you specify depends on your Python version.

VersionURL
Linux
Python 2.7 CPU-only https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-2.0.0-cp27-cp27mu-manylinux2010_x86_64.whl
Python 2.7 GPU support https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.0.0-cp27-cp27mu-manylinux2010_x86_64.whl
Python 3.5 CPU-only https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-2.0.0-cp35-cp35m-manylinux2010_x86_64.whl
Python 3.5 GPU support https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.0.0-cp35-cp35m-manylinux2010_x86_64.whl
Python 3.6 CPU-only https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-2.0.0-cp36-cp36m-manylinux2010_x86_64.whl
Python 3.6 GPU support https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.0.0-cp36-cp36m-manylinux2010_x86_64.whl
Python 3.7 CPU-only https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-2.0.0-cp37-cp37m-manylinux2010_x86_64.whl
Python 3.7 GPU support https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.0.0-cp37-cp37m-manylinux2010_x86_64.whl
macOS (CPU-only)
Python 2.7 https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.0.0-py2-none-any.whl
Windows
Python 3.5 CPU-only https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-2.0.0-cp35-cp35m-win_amd64.whl
Python 3.5 GPU support https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.0.0-cp35-cp35m-win_amd64.whl
Python 3.6 CPU-only https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-2.0.0-cp36-cp36m-win_amd64.whl
Python 3.6 GPU support https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.0.0-cp36-cp36m-win_amd64.whl
Raspberry PI (CPU-only)
There is no TensorFlow 2 support for RPi yet, it is expected in a future release
Python 2.7, Pi0 or Pi1 https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-1.14.0-cp27-none-linux_armv6l.whl
Python 2.7, Pi2 or Pi3 https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-1.14.0-cp27-none-linux_armv7l.whl
Python 3, Pi0 or Pi1 https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-1.14.0-cp34-none-linux_armv6l.whl
Python 3, Pi2 or Pi3 https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-1.14.0-cp34-none-linux_armv7l.whl