Tensorflow-GPU on Windows with NVIDIA

If you are planning on setting up a dockerized tensorflow-gpu environment on your Windows machine. Please don’t. Your gonna have a really bad time. They are still working on proper support though, hope is still there.

Instead, as of now, set it up directly on Windows!

Installation in case of NVIDIA graphics card

  1. Install CUDA support properly by following instructions: Installation Guide :: NVIDIA Deep Learning cuDNN Documentation
  2. Watch out for correct CUDA / cuDNN version, in case you want to use an older tensorflow version for your project
compatibility matrix tensorflow-gpu versus CUDA and cuDNN. See tested versions in https://www.tensorflow.org/install/source_windows
  1. Setup a new python environment. Tip: use anaconda and pip
  2. Install Tensorflow-GPU, e.g. with pip install tensorflow-gpu

Check your installation

Open your new python environment and issue following commands

For Tensorflow 1.x

from tensorflow.python.client import device_lib
device_lib.list_local_devices()

For Tensorflow 2.x

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

There should be no warnings and errors. You should see something like this in your python terminal:

2020-12-26 08:03:30.457651: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
 2020-12-26 08:03:30.517230: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
 pciBusID: 0000:01:00.0 name: GeForce GTX 1650 with Max-Q Design computeCapability: 7.5
 coreClock: 1.245GHz coreCount: 16 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.34GiB/s
 2020-12-26 08:03:30.517784: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
 2020-12-26 08:03:31.288469: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
 2020-12-26 08:03:31.288705: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
 2020-12-26 08:03:31.381785: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
 2020-12-26 08:03:31.434105: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
 2020-12-26 08:03:32.126894: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
 2020-12-26 08:03:32.433552: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
 2020-12-26 08:03:32.461163: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
 2020-12-26 08:03:32.461578: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
 [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Troubleshooting

If you see any warnings or errors when issuing the above statements:

  1. make sure once again that you have installed correct versions of CUDA and cuDNN which were tested with the version of tensorflow you are using (see https://www.tensorflow.org/install/source_windows).
  2. reboot your computer

Now you can go ahead and have fun while experiencing a significant performance boost when training e.g. a CNN.