Setup Tensorflow GPU in Windows- The quick way

Sourav Garai
2 min readDec 19, 2020

After days of struggle I figured out the simple 4 steps procedure to make tensorflow use your machine’s NVIDIA GPU. It takes about 3GB of download and 30 min of installation.

Step 1 — Install CUDA v11.0 and NOT the latest version.

Installing correct version of CUDA is the most important step while setting up tensorflow with gpu support. Make sure you install v11.0 and not the latest version of cuda as only v11.0 is supported by the current build of tensorflow gpu. Here is the link to download cudnn-11.0-windows-x64-v8.0.4.30 CUDA Toolkit 11.0 Download | NVIDIA Developer.

Step 2 — Install CUDNN v8.0 for CUDA 11.0 and NOT any other version

Download cuDNN for v8.0 from Download cuDNN v8.0.4 (September 28th, 2020), for CUDA 11.0. Just extract to a location like C:/tools/

Step 3 — Setup path variables

Add these 4 paths to your windows environment. (Click start -> type ‘path’)

  1. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin

2. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\extras\CUPTI\lib64

3. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include

4. C:\tools\cuda\bin (this is the extracted cuDNN)

Step 4- Install tensorflow

pip install tensorflow

This installs tensorflow 2 with GPU support

Check with this simple code. If output value ≥1 you GPU will be automatically used by tensorflow.

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

That’s all folks. May the force be with you!

Links for reference.

GPU support | TensorFlow

--

--