The fastest, easiest way to get started with deep learning on GPUs
Speed Up Training with GPU-Accelerated TensorFlow
System Requirements

The GPU-enabled version of TensorFlow has the following requirements:

  • 64-bit Linux
  • Python 2.7
  • CUDA 7.5 (CUDA 8.0 required for Pascal GPUs)
  • cuDNN v5.1

You will also need an NVIDIA GPU supporting compute capability 3.0 or higher.

Download and Installation Instructions

TensorFlow is distributed under an Apache v2 open source license on GitHub. This guide will walk through building and installing TensorFlow in a Ubuntu 16.04 machine with one or more NVIDIA GPUs.

TensorFlow site is a great resource on how to install with virtualenv, Docker, and installing from sources on the latest released revs.


Step 1. Update/Install Nvidia Drivers

Install up-to-date NVIDIA drivers for your system.

$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt update (re-run if any warning/error messages)
$ sudo apt-get install nvidia- (press tab to see latest). 375 (do not use 378, may cause login loops)

Reboot to let graphics driver take effect.

Step 2. Install and Test CUDA

To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit by following the official documentation. Steps for CUDA 8.0 for quick reference as follow:

Navigate to https://developer.nvidia.com/cuda-downloads.

Select Linux, x86_64, Ubuntu, 16.04, deb (local).
$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb (this is the deb file you've downloaded)
$ sudo apt-get update
$ sudo apt-get install cuda

If you encounter message suggesting to re-perform sudo apt-get update, please do so and then re-run sudo apt-get install cuda.

$ export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Test your CUDA installation:

$ cd /usr/local/cuda-8.0/samples/5_Simulations/nbody
$ sudo make
$ ./nbody

If successful, a new window will popup running n-body simulation.

Step 3. Install cuDNN

Once the CUDA Toolkit is installed, download cuDNN v5.1 Library for Linux and install by following the official documentation. (Note: You will need to register for the Accelerated Computing Developer Program). Steps for cuDNN v5.1 for quick reference as follow:

Once downloaded, navigate to the directory containing cuDNN:

$ tar -xzvf cudnn-8.0-linux-x64-v5.1.tgz
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Now that the prerequisites are installed, we can build and install TensorFlow.

Step 4. Prepare TensorFlow Dependencies and Required Packages

$ sudo apt-get install libcupti-dev

Step 5. Install TensorFlow (GPU-accelerated version)

$ pip install tensorflow-gpu

Step 6. Verify a Successful Installation

Let’s quickly verify a successful installation by first closing all open terminals and open a new terminal.

Change directory (cd) to any directory on your system other than the tensorflow subdirectory from which you invoked the configure command.

Invoke python: type python in command line

Input the following short program:

$ import tensorflow as tf
$ hello = tf.constant('Hello, TensorFlow!')
$ sess = tf.Session()
$ print(sess.run(hello))

You should see “Hello, TensorFlow!”. Congratulations! You may also input “print(tf.__version__)” to see the installed TensorFlow’s version.