TensorFlow 2 packages are available
tensorflow
—Latest stable release for CPU-onlytensorflow-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-onlytensorflow-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:
python3 --version
pip3 --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 python3-dev python3-pip
sudo pip3 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 # Python 3
sudo pip3 install -U virtualenv # system-wide install
Windows
Install the Microsoft Visual C++ 2015 Redistributable Update 3. This comes with Visual Studio 2015 but can be installed separately:
- Go to the Visual Studio downloads,
- Select Redistributables and Build Tools,
- Download and install the Microsoft Visual C++ 2015 Redistributable Update 3.
Make sure long paths are enabled on Windows.
Install the 64-bit Python 3 release for Windows (select pip
as an optional feature).
pip3 install -U pip virtualenv
Raspberry Pi
Requirements for the Raspbian operating system:
sudo apt update
sudo apt install python3-dev python3-pip
sudo apt install libatlas-base-dev # required for numpy
sudo pip3 install -U virtualenv # system-wide install
Other
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
sudo pip3 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 python3 ./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:
virtualenv --system-site-packages -p python3 ./venv
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=3.7 # select python version
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
pip3 install --user --upgrade tensorflow # install in $HOME
Verify the install:
python3 -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.
Version | URL |
---|---|
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 |