Installing Tensorflow on GPU

DaurEd
2 min readJan 23, 2021

Here is my experience of getting tensorflow recognize GPU on windows 10.

Its not always smooth. However, few hints from the blog could help you get there quicker.

Hardware: GeForce RTX 2060 with Max-Q Design (All you need is a CUDA enabled card)

Num GPUs Available: 1

Before beginning any installations, check out the compatibility table here. The GPU. The combination that worked for me is: conda install tensorflow-gpu==2.1.0 with CUDA 10.1 toolkit & corresponding cuDNN

Sign up on Nvidia website.

Steps:

  1. Installing microsoft C++ redistributable.
  2. Nividia drivers
  3. CUDA toolkit (Make sure you install Visual Studio community edition prior to CUDA toolkit)
  4. Install cuDNN .
  5. Copy the files from bin, include & lib folders from the cuDNN folder to CUDA folder.

cudnn64_8.dll from Bin, cudnn.h from Include & cudnn.lib from lib folder are the important files that needs to be pasted to corresponding floders in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

Verify once that the Path points at the right location.

I recommend having a conda env with a python version specified:

conda create — name tf-gpu7 python=3.7

Install a tf version of appropriate choice :

conda install tensorflow-gpu==2.1.0

Activate the environment by: conda activate tf-gpu7

The following commands with trigger your python , you can check the version of python and tensorflow.

(tf-gpu7) C:\Users\piyus>python

>>> import tensorflow as tf

>>> print(“Num GPUs Available: “, len(tf.config.experimental.list_physical_devices(‘GPU’)))

If the output is as shown in the pic above, GPU is found. It also tells you the GPU card used.

To verify Tensorflow version installed:

>>> tf.version.VERSION

To check the CUDA toolkit info:

(tf-gpu7) C:\Users\piyus>conda list cudatoolkit

To know the cuDNN version:

(tf-gpu7) C:\Users\piyus>conda list cudnn

Some installations work only you restart the system.

Hope these pointers would cover all the frequently faced hurdles in getting the Tensorflow working with the underlying GPU hardware.

-Writer: Piyush Kulkarni (Data Scientist)

--

--

DaurEd

Our objective is to be valued leader in providing quality, affordable instruction in studies via practical training, workshops, & experimental learning.