KEMBAR78
SETUP CUDA + CuDNN + PyTorch + Tensorflow (Windows) | PDF | Computing Platforms | Computer Architecture
0% found this document useful (0 votes)
33 views21 pages

SETUP CUDA + CuDNN + PyTorch + Tensorflow (Windows)

This tutorial provides a step-by-step guide on setting up CUDA, CuDNN, PyTorch, and TensorFlow on Windows, highlighting compatibility issues and installation procedures. Key steps include installing the NVIDIA Video Driver, Visual Studio C++, Anaconda, CUDA Toolkit, and CuDNN, along with verifying installations. The document also includes references for further assistance and troubleshooting common problems encountered during the setup process.

Uploaded by

alexjoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views21 pages

SETUP CUDA + CuDNN + PyTorch + Tensorflow (Windows)

This tutorial provides a step-by-step guide on setting up CUDA, CuDNN, PyTorch, and TensorFlow on Windows, highlighting compatibility issues and installation procedures. Key steps include installing the NVIDIA Video Driver, Visual Studio C++, Anaconda, CUDA Toolkit, and CuDNN, along with verifying installations. The document also includes references for further assistance and troubleshooting common problems encountered during the setup process.

Uploaded by

alexjoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

AUTHOR : MAXENCE QUINET

HOW TO SETUP CUDA + CuDNN + PyTorch + Tensorflow


(Windows Tutorial)

In this tutorial, we will see how to setup CUDA + CuDNN + PyTorch +


Tensorflow and how to works with GPU.
There is a lot of problems of compatibility, so please, take time to follow this
tutorial carefully.
You can find some references at the end of this Word file. Like YouTube
video tutorials and some forums that help me to find solution(s) for
problem(s).

STEP 1: NVIDIA Video Driver


First, you have to install your NVIDIA Video Driver.
Go to the Windows Search Tab, and tap NVIDIA Control Panel, and if you get
the following window, it means that the particular drivers are already
installed :
AUTHOR : MAXENCE QUINET

Otherwise, go to this link → https://www.nvidia.com/en-us/drivers/


You will appear on this page, on the list bar, configure your choice
depending on your GPU. Then, download the .exe file corresponding to your
GPU. The drivers will be installed automatically.

By clicking on “FIND” you will appear in a new window, with GeForce Game
Ready Driver & NVIDIA Studio Driver. Install both.
AUTHOR : MAXENCE QUINET

STEP 2: Visual Studio C++


This step is MANDATORY AND TRICKY. Please, read carefully.
CUDA & CuDNN need some C++ Compiler to work well. And you can install
these C++ compilers using the Visual Studio Installer.
BUT during the last weeks, a lot of people encounter problems during
installation of CUDA. During the installation, the progress bar was stuck on
“NVIDIA Insights Installation”.
Thanks to this NVIDIA forum (15 February 2025, so very recent) :
https://forums.developer.nvidia.com/t/stuck-installing-nsight-on-cuda-12-
8-0-571-96-windows/323732/7

I have discovered that the problem is because the current version of Visual
Studio Community 2022 has some compatibility problems with CUDA.
(Fuck this shit)
So, you must install the previous version of Visual Studio Community 2022.
But know what? They don’t give release on the website. L.M.A.O.
But be safe, I am here to save you (<3).
We will use the Windows PowerShell (open as administrator) and a
command to install old version. Personally, it works with version 17.12.0
(see the forum if you want other versions given by people)
First, if you have one current version of Visual Studio Community & Visual
Studio Installer installed on your computer, please, uninstall them to not
create problems with new installation and variables path.

Then go on this website →


https://visualstudio.microsoft.com/vs/community/
And Download Visual Studio Installer on a findable directory.
AUTHOR : MAXENCE QUINET

When installed, open Windows PowerShell as administrator :

Put the command ‘cd’ to the directory with your VisualStudioInstaller.exe


component:
cd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe"
Then, do this command to open VisualStudioInstaller in the
.\VisualStudioSetup.exe --channelUri
https://aka.ms/vs/17/release.LTSC.17.12/channel --locale en-US

The last option ‘—locale en-US’ is because you will have to install a lot of
packages and the name change a lot between language, so it’s better to
search by the official names (English).
AUTHOR : MAXENCE QUINET

Then, install “Dekstop development with C++”. It will cross a lot of packages
needed:

Then go in Individual Components:

And be sure to have crossed ALL these packages.


Obviously, some packages have maybe different versions when you
read this file. If the name is fully same, but instead to have v14.16 you
have v14.17, install it)
AUTHOR : MAXENCE QUINET

List: (Normally, the components are listed in the same order as the
VisualStudioInstaller, so you can follow them one after the other)
On the first .NET column:
- .NET Framework 4.6.1 targeting pack
- .NET Framework 4.7.2 targeting pack
- .NET Framework 4.8 SDK
On the first AI Assistance column:
- GitHub Copilot (your bestfriend)
On the first Code tools column:
- NuGet package manager
- Text Template Transformation
- Vcpkg package manager
On the first Compilers, build tools, and runtime (the most important!)
column:
- C# and Visual Basic Roslyn compilers
- C++ 2022 Redistributable MSMs
- C++ 2022 Redistributable Update
- C++ Build Insights
- C++ Clang Compiler for Windows (18.1.8)
- C++ CMake tools for Windows
- C++ Modules for v143 build tools (x64/x86 – experimental)
- C++ Universal Windows Platform support for v143 build tools
(ARM64/ARM64EC)
- C++ Windows XP Support for VS 2017 (v141) tools [Deprecated]
- C++/CLI support for v141 build tools (14.16)
- C++/CLI support for v142 build tools (14.29-16.11)
- C++/CLI support for v143 build tools (14.36-17.6)
- C++/CLI support for v143 build tools (14.38-17.8)
- C++/CLI support for v143 build tools (14.39-17.9)(Out of support)
- C++/CLI support for v143 build tools (Latest)
- MSBuild
- (at the bottom of the column) Windows Universal CRT SDK
AUTHOR : MAXENCE QUINET

Normally, other cases should be crossed. That’s normal. Let them.

NOTES, please be free to update this document if you find new notes
that you think is suitable to know for other people:
• CUDA & CuDNN doesn’t work with 32 bits configuration. ONLY with
64bits configuration.

THEN, CLICK ON INSTALL (TAKES TIME)

Verify if it’s installed:


Go to C:\Program Files (x86)\Microsoft Visual Studio\Installer
If you have a lot of things installed as in the photo, everything goods :
AUTHOR : MAXENCE QUINET

STEP3: Anaconda (or MiniConda)


Sorry for my laziness, but I have already installed Anaconda. So I didn’t do
this step.
But you just have to install Anaconda Navigator from the website and cross
the case “Add to PATH environment variables”.
And that’s it.
You can watch this video from 8:40 if you want to know how to configure
anaconda if it’s doesn’t the case in your laptop :
https://www.youtube.com/watch?v=nATRPPZ5dGE

STEP4: CUDA Toolkit


OK. Please, read carefully the following paragraphs:
Your GPU, CUDA, PyTorch and Tensorflow are compatible with some
versions only. Here are some explanations:
- When you import torch (PyTorch), the package includes its own
version of CUDA. That's why it's easier to install PyTorch than
Tensorflow. But, if you want to work with both in the same project, you
need to install a version of CUDA that is supported/compatible with
both.
- Latest PyTorch requires Python 3.9 or later
AUTHOR : MAXENCE QUINET

Now, go to the command prompt, and tape the command:


nvidia-smi
You will see this window:
AUTHOR : MAXENCE QUINET

As you can see on the top right, there is “CUDA Version: XX.X”.
This means that your GPU is compatible UP TO this version of CUDA.
(So, this version, and all previous versions). In my case, I can use every
CUDA version until 12.6.

Now, we will check the PyTorch compatibility versions.


Go to this link → https://pytorch.org/get-started/locally/

As you can see, PyTorch will works with his own version of CUDA (11.8, 12.4
and 12.6 at the moment when I write this tutorial)

Then click on this link to choose which version of CUDA you will install:
https://developer.nvidia.com/cuda-toolkit-archive

I advise you to install CUDA Toolkit 12.1.0 (February 2023). It works for
me.
AUTHOR : MAXENCE QUINET

Choose your OS, Architecture, Version of Windows.


Installer Type : .exe (local)

Then, double click on the .exe cuda installer file.


AUTHOR : MAXENCE QUINET

Wait a little bit…

Then click on Express (Recommended)

Wait a little bit… (Note: the step ‘Installing Nsight Visual Studio Edition
could take 30s – 1min. Maybe 5min in some computers. BUT, if this time
loading exceed 10-15min, consider that you version of Microsoft Visual
Studio Community encounter a problem, and your installation is currently
stuck. You have to go back in this forum and follow tips given by people
community → https://forums.developer.nvidia.com/t/stuck-installing-
nsight-on-cuda-12-8-0-571-96-windows/323732/7
but if you have followed my steps, you shoudn’t encounter any problem)
AUTHOR : MAXENCE QUINET

After some moment it will be done:

Click on ‘NEXT’, and ‘FINISH’.

Verify if CUDA is installed:


Go to C:\Program Files\NVIDIA GPU Computing Tools\CUDA\v12.1
You should see all these components:
AUTHOR : MAXENCE QUINET

STEP5: INSTALL CUDNN


To install CUDNN go to this link : https://developer.nvidia.com/rdp/cudnn-
archive

As you can see, you can install some version for 12.x versions or 11.x
versions etc…

Personally, I have take the last version, so CuDNN v8.9.7 (December 5th,
2023), for CUDA 12.x.
Then, install the Local installer for Windows (ZIP)
AUTHOR : MAXENCE QUINET

Extract the zip file. You should have this

Go to bin:

Copy all theses components, and paste them into the bin file of you CUDA
installation :
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin
AUTHOR : MAXENCE QUINET

Do the same for include.

Then, for lib → x64.


AUTHOR : MAXENCE QUINET

VERIFY IF CUDA & CUDNN ARE INSTALLED


Go to your environment variables:

You should see 2 new System variables:


• CUDA_PATH
• CUDA_PATH_V12_1
With the same paths.

It they are not present, add them manually, taking Path examples of my
pictures.
AUTHOR : MAXENCE QUINET

DONE FOR SETUP. LET’S NOW SEE IF IT WORKS

First of all, here some notes about Tensorflow (findable here →


https://www.tensorflow.org/install/pip?hl=fr#windows-native)

• Tensorflow version 2.10 was the LAST version working with GPU and
compatible WITH NATIVE WINDOWS!
• Tensorflow version above 2.10 are compatible with Windows, but
need WSL2 Installation !
• Tensorflow versions above 2.10 & Windows/WSL2 works ONLY if your
Windows 10 version is above 19044 (64bits)

How to verify your Windows 10 versions:


Tape:
Win + R
Tape:
Winver
AUTHOR : MAXENCE QUINET

Now, you have all informations. Obviously, I will install tensorflow 2.10
for the moment.

As you can see, I have installed PyTorch 1.13 with cuda 11.6 & Tensorflow
2.10.1.

To install the same versions as me:


• pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116
torchaudio==0.13.1 --extra-index-url
https://download.pytorch.org/whl/cu116
• pip install tensorflow==2.10.1

Obviously, I advise you to create conda environment with these


installations to not have problems with other environments.

Then, activate your environment, and open Jupyter notebook.


Copy/Paste this code:
import torch
print("Number of GPU: ", torch.cuda.device_count())
print("GPU Name: ", torch.cuda.get_device_name())
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device: ', device)
AUTHOR : MAXENCE QUINET

import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
tf.test.is_gpu_available()
print("PyTorch version:", torch.__version__)
print("TensorFlow version:", tf.__version__)

If you have the same results as me in the pictures, it means that everything
works:

IMPORTANT NOTE:
I didn’t test yet to import tensorflow using WSL2 (which is mandatory when
you want to use tensorflow version above 2.10). I will maybe do it later. But
please, if you did it, add a section after this one to explain how to do it.
Thanks in advance.

CONGRATULATIONS
AUTHOR : MAXENCE QUINET

References:
• Video Tutorial (not cover all possible problem):
https://www.youtube.com/watch?v=nATRPPZ5dGE
• GitHub Steps with website links: https://github.com/entbappy/Setup-
NVIDIA-GPU-for-Deep-Learning
• NVIDIA Forum (VS Community Compatibility problem):
https://forums.developer.nvidia.com/t/stuck-installing-nsight-on-
cuda-12-8-0-571-96-windows/323732/12 &
https://forums.developer.nvidia.com/t/cuda-install-hangs-forever-
windows-10-geforce-920m/77580/4

Thanks for reading, hope it was useful and working for you.

You might also like