Complete Guide to TensorFlow-GPU Installation on Windows 10

Soumyadip Majumder
4 min readOct 9, 2018

--

When I first started working on Deep Learning models, I used Keras with TensorFlow in backend.

So, initially I used the TensorFlow-cpu version and the model used to take long time to train on images. I remember, one project I was working on, it used to take 26 minutes just for one epoch. There were other instances, where I was training my model continuously for 5 days.

Finally I gave up on my patience and started looking for the benefits of using TensorFlow GPU version. I went through lot of articles and benchmarks. Below are two of those articles:

Introduction to TensorFlow — CPU vs GPU

TensorFlow performance test: CPU VS GPU

Without wasting more time, let’s start with the installation guide.

Prerequisites:

· NVIDIA GPU (GTX 650 or newer. GeForce GTX 1050 4GB is a decent entry level choice)

· CUDA Toolkit 9.0

· CuDNN 7.0.5

· Anaconda with Python 3.6

NVIDIA GPU and Driver Installation-

I am currently working on two laptops. At work, I use a laptop with GeForce GTX 1070 (8GB). At home, I use my personal laptop with GeForce GTX 1050 (4GB).

If you are using any high end GPUs like GTX 1070 or 1080/Ti, your latest driver will be compatible with the CUDA 9.0 and CuDNN 7.0 by default. So, you don’t need to worry.

If you are using a bit older GPU like GTX 1050, first you need to uninstall the driver and all related components completely. The best way to do so is to have Revo Uninstaller on your system. Uninstall all NVIDIA driver components by selecting “Advance” option in Revo Uninstaller.

Once the GPU driver is uninstalled, download NVIDIA GPU driver version 387.92 and install it on your system.

[Warning: Do not update the driver after installing 387.92]

CUDA Toolkit 9.0-

Download CUDA Toolkit from this link.

Select:

Operating System: Windows

Architecture: x86_64

Version: 10

Installer Type: exe[local]

Then download the base installer (size ~1.4GB)

CUDA Download

Set Environment Variables:

Go to Start and type Environment Variables. You will see “Edit the system environment variables”. Click on it.

Advanced System Properties

Now click on the Environment Variables… button at the bottom right corner. It will open the below window.

Environment Variables

Double Click on the Path under “System Variables”.

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64

Then save it.

CuDNN 7.0.5-

To download CuDNN 7.0.5, visit the CuDNN archive site.

You have to login or create a user profile(if you do not have profile) as NVIDIA Developer.

You will find the archive “Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0”. Download the Windows 10 version.

CuDNN v7.0.5

Extract the downloaded CuDNN zip file contents.

Copy the contents to C: drive or somewhere else as per your ease.

I placed the contents in C: drive in a folder CUDA.

Inside CUDA, there will be three or four folders.

CUDA Folder

Similar to the Environment Variables Setup of CUDA Toolkit 9.0, we have to the same for CuDNN path setup.

Open to the Path of “System Variables” and paste the path of bin folder:

C:\cuda\bin

Now the Path should look something like this:

Path

Once this is done, you are good to update your GPU Driver. You can use GeForce Experience to update the driver or any other process that you follow to update it.

Anaconda-

I installed Anaconda with Python 3.6 version (64 bit).

While installing Anaconda, check “add python to your PATH” option during the install.

Right now Anaconda with Python 3.7 and Python 2.7 are available at their Download page. If you want python 3.6, you can refer to their FAQ page.

First install the latest version of Anaconda and then create a python 3.6 environment using:

conda install python=3.6

Install TensorFlow-

Finally, you are set to install TensorFlow-GPU version on your system.

Open CMD and type

pip install --ignore-installed --upgrade tensorflow-gpu

You can refer to the Official Installation Guides.

To check if TensorFlow is installed correctly:

Open cmd

Type python

Enter the below commands:

import tensorflow as tf

a= tf.constant(4)

b=tf.constant(5)

sess=tf.Session()

c= a+b

print(“Sum= ”, sess.run(c))

TensorFlow Test

It will print the output 9.

This means your installation is successfully completed and you are good to go.

Hope this tutorial is helpful. If you have questions or doubt , drop them below in the comment section.

--

--