TensorFlow GPU 2.7.0 on Windows 10

Install Visual Studio 2019 in 2022 for CUDA 11.2 and cuDNN 8.1.1

Pierre-Yves Dumas
4 min readDec 1, 2021

--

I like Windows, don’t judge me, but when it comes to Machine Learning it can be a bumpy ride. Here’s a short walkthrough with verbose on to get TensorFlow GPU 2.7.0 to work on Windows 10.

Make sure your GPU is CUDA-Enabled

The very first step is to make sure you have an appropriate GPU. This is not specific to Windows. Your GPU should be in this list, likely in the “CUDA-Enabled GeForce and TITAN Products” tab. Mind that there are two columns, one for regular desktops on the left, and one for notebooks on the right. They are NOT the same, for instance the GeForce GTX 1050 is listed for desktops, but not for laptops. Sometimes the Titans are listed separately, like the GeForce GTX 1080 Ti and the GeForce GTX 1080 both listed for desktops, but some GPUs that are not listed, like the RTX 3080 Max-Q, may work just fine. Max-Qs (the least good, even compared to the base GPU), Supers and Titans are likely to work the same way as their base GPU. But if the base GPU is not listed, like the RTX 1660 Super for desktops, don’t expect it to work. If you want to keep it safe, stick to the list.

I received recently a GeForce RTX 3060 for notebooks, its compute capability is 8.6, which is the same as with a GeForce RTX 3050, 3070 or 3080, either for desktops or for notebooks. So if you don’t care abou video games or mining, the GeForce RTX 3060 for notebooks is a great pick.

Install Visual Studio 2019 in 2022 for CUDA 11.2

You’ll need 2019 C++ Visual Studio. As of December 2021, the 2022 version doesn’t work with the CUDA installer. It’s true as well for NVDIA Nsight. Microsoft made it stupidly difficult to find the 2019 version. If you don’t have the correct version, you’ll see the following message later on: “No supported version of Visual Studio found. Some components of the CUDA Toolkit will not work properly.”

Fortunately for you, here’s the link you need. I got it from that page, although the 2019 version is absent from it, the link to the 2022 community version is https://aka.ms/vs/17/release/vs_community.exe so I tried to see what https://aka.ms/vs/16/release/vs_community.exe would give me and I was lucky enough for it to be the coveited 2019 version. Thank you, Microsoft, for trying to make my life easier.

The missing link to Visual Studio 2019 is https://aka.ms/vs/16/release/vs_community.exe

Install the C++ workload.

Unzip cuDNN v8.1.1 (Feburary 26th, 2021), for CUDA 11.0, 11.1 and 11.2

You need an NVIDIA account to download cuDNN 8.1.1 from here. If you’d rather want to download it from the archive list, mind that this must be the right version of cuDNN for the right version of CUDA, and of course on the right platform.

Unzip cuDNN anywhere you want. For me the bin folder has that path: C:\_\run\cudnn-11.2-windows-x64-v8.1.1.33\cuda\bin. I use _ as a nod to the ~ in Linux but easier to type.

Do make that library available to your runtime, and not get some cublas64_11.dll, cublasLt64_11.dll, cufft64_10.dll, curand64_10.dll, cusolver64_11.dll, cusparse64_11.dll or cudnn64_8.dll error, you must add this bin folder to the path in the environment variables.

Install CUDA 11.2

The CUDA 11.2 installer can be downloaded here. You can go for the express installation or customize the directories.

Enjoy TensorFlow GPU 2.7.0 on Windows 10

You can use PyCharm, configure a Python 3.8 venv and import the TensorFlow 2.7.0 package. Using TensorFlow should print something like:

Created device /job:localhost/replica:0/task:0/device:GPU:0 with 3495 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3060 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6

Using anything GPU related should print:

Loaded cuDNN version 8101

You can verify that your GPU is active with:

print("Num GPUs Available: " + str(len(tf.config.experimental.list_physical_devices('GPU'))))

This should print:

Num GPUs Available: 1

Congratulation!!! The power of your GPU is now yours on Windows 10!!! One thing you may want to do next is to share a virtual environment between PyCharm and Anaconda.

--

--