How to install TensorFlow with GPU support on Windows 10 with Anaconda

TensorFlow programs run faster on GPU than on CPU. If your system has a NVIDIA® GPU meeting the prerequisites, you should install the GPU version.

Requirement

CUDA® Toolkit 8.0.

cuDNN v5.1

GPU card with CUDA Compute Capability 3.0 or higher. See NVIDIA documentation for a list of supported GPU cards.

Install Anaconda

Download Anaconda For Windows Graphical Installer here

Set up NVIDIA® GPU support

Download and install CUDA® Toolkit 8.0: https://developer.nvidia.com/cuda-downloads

Download cuDNN v5.1: https://developer.nvidia.com/cudnn
Note: You need to sign up at Nvidia in order to download these files.

Now extract the cuDNN v5.1 file. You will get a cuda folder with 3 subfolders bin, include, and lib inside.

Copy and paste all 3 into the Toolkit directory at “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0”

Set up environmental variables:

In Search, search for and then select: System (Control Panel)

Click the System Advanced setting

Click on Environment Variables

Add the CUDA_HOME variable in the System variables. The value is “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0” (the path to your Toolkit folder)

Also the path variables

The values are:

“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64”

“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64”

Install TensorFlow with Anaconda

Open Anaconda Prompt (Search -> Anaconda Prompt)

Create a Python 3.5 conda environment named tensorflow by invoking the following command:

C:> conda create -n tensorflow python=3.5

Activate the conda environment tensorflow by issuing the following command:

C:\User\*your username*> activate tensorflow

Your prompt should change into

(tensorflow)C:\User\*your username*>

Instal TensorFlow with GPU support

(tensorflow)C:\User\*your username*> pip install tensorflow-gpu

Done.

Validate your installation

Start the Anaconda Prompt and activate the conda environment tensorflow

C:\User\*your username*> activate tensorflow

Your prompt should change into

(tensorflow)C:\User\*your username*>

Invoke Python

python

Enter the short program below

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

If the system outputs the following, then you are ready to begin writing TensorFlow programs:

Hello, TensorFlow!

Test the GPU

Start the Anaconda Prompt and activate the conda environment tensorflow

C:\User\*your username*> activate tensorflow

Your prompt should change into

(tensorflow)C:\User\*your username*>

Invoke Python

python

Enter the short program below

import tensorflow as tf

And

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))