Enable NVIDIA GPU Support for Tensorflow-2.8 (Windows 11)

***Intended for every step to be completed in sequential order

I am assuming that you have Python and TensorFlow installed.

First check your TensorFlow and Python version in the following table:

https://www.tensorflow.org/install/source_windows#gpu

I have python 3.9.4 and tensorflow 2.8 so I need cuDNN 8.1 and CUDA 11.2.

You can ignore the “Compiler” and “Build tools” columns for this tutorial.

Next check that your GPU is supported:

You can find your GPU model in your Advanced Display Settings.

To check if your GPU is supported go to https://en.wikipedia.org/wiki/CUDA#GPUs_supported and look up the relevant CUDA Version.

For CUDA 11.2 there is support for compute capability 3.5–8.6 (Kepler (in part), Maxwell, Pascal, Volta, Turing, Ampere).

Below the bulleted list of supported CUDA level and compatible GPUs is a table that includes a comprehensive list of NVIDA GPUs. Ctr-f for the name of your GPU.

In the far left column it will list the “Compute capability (version)”. To install 11.2 the compute capability needs to be between 3.5 and 8.6 (inclusive).

The RTX 3070 has compute capability 8.6 so it is compatible.

Now we can start installing

***Install the following in order.

  1. NVIDIA® GPU drivers — Look up your GPU. I installed the studio version, but either version should be fine. Select search. Then select download. Follow all prompts.

2. Restart your computer.

3. Visual Studio 2019 — Download Community 2019. I already had VS 2022 installed, but this didn’t cause any issues. I could leave VS 2022 installed. Follow all of the prompts. You don’t need any of the addons.

*** You must have Visual Studio 2019 or you will get an error in the next step

4. CUDA Toolkit 11.2 — Click the link. Select Operating System: Windows, Architecture:x86_64, Version: 10, installer type: exe(local). (Not sure if the version matters but I selected 10 and it worked) — Download the base installer and follow the onscreen prompts. If it says can’t find Visual Studio make sure you have Visual Studio 2019 installed.

5. NVIDA Developer Account — You need to sign up for an NVIDA Developer account. Yes, it’s required. Yes, it’s free. You’re just so cool that they want to get to know you before you download the CUDA® Deep Neural Network library (cuDNN).

6. cuDNN SDK 8.1.0 —This is an archived version of cuDNN. Make sure you don’t download the most recent version.

Select “Download cuDNN v8.1.0 (January 26th, 2021), for CUDA 11.0,11.1 and 11.2”

Click on “cuDNN Library for Windows (x86)” — This should download a zip file. Unzip it. Open the “cuda” folder.

  1. Drag all the files in \cuda\bin into C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin.
  2. Drag all the files in \cuda\include into C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include.
  3. Drag all the files in \cuda\lib\x64 into C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib\x64.

Search for “Environmental Variables” in the windows search bar.

Select “ Edit the system environment variables”

Select the Advanced tab at the top of the window.

Click Environment Variables at the bottom of the window.

Ensure the following values are set:

Variable Name: CUDA_PATH Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2

Your Done!

Tensorflow should now recognize your GPU and use it when appropriate. The next time you use TensorFlow you should get the following message:

My runtimes are significantly reduced. I hope you see some benefits too!

--

--