This post is based on a tutorial: Installing Tensorflow with CUDA, cuDNN and GPU support on Windows 10 from Dr. Joanne Kitson.

I will not be repeating the post but rather highlight the important steps to setup on your own machine. This works for Pytorch too. I included snippet of code to test your Pytorch is using GPU at the end.

For CUDA official site, refer here

Step 1: Tensorflow version

Figure out which tensorflow version you will be using. This will affect the CUDA and cuDNN libraries that you need.

Refer here for the specific tensorflow version and corresponding CUDA and cuDNN version.

Step 2: Install Visual Studio Express. (Might need a reboot)

Step 3: Download CUDA toolkit for Win 10

You might need to access the archive versions if your required CUDA version is not the latest.

Step 4: Download cuDNN

Step 5: Unzip cuDNN files and copy to CUDA folders

  • cudnn64_7.dll
  • cudnn.h
  • cudnn.lib

Step 6: Set CUDA env variables

Check that CUDA_PATH env variable is set to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v<x.x> or whichever directory you have saved your CUDA.

Step 7: Install Python and Tensorflow

Step 8: Test configuration

For Tensorflow,

import tensorflow as tf
tf.config.list_physical_devices('GPU')

# Result:
# [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

For Pytorch,

import torch
torch.cuda.is_available()

# Result:
# True

Leave a comment