CUDA and cuDNN installation tutorial (super detailed)

foreword

To install CUDA on windows10 and win11, you first need to download two installation packages

CUDA toolkit (toolkit refers to the toolkit)
cuDNN is used to configure deep learning

official tutorial

CUDA:Installation Guide Windows :: CUDA Toolkit Documentation (nvidia.com)

cuDNN:Installation Guide :: NVIDIA Deep Learning cuDNN Documentation

Download and install cuda

cuda version

Judging which version of cuda should you download?

Open nvidia (right click on the desktop) -> select system information in the lower left corner -> components

The version here is backward compatible, that is, according to the principle that it is generally not recommended to use the latest version of the development library, our graphics card and driver here support up to cuda11.2, but we still choose version 10.1 to complete the development work.

You can also enter directly in cmd

nvidia-smi

Check the cuda version supported by your graphics card.

CUDA toolkit Download

CUDA Toolkit Archive | NVIDIA Developer

 Click in, select according to the following configuration, and then click download:

 Here we use the offline installation method to download the exe executable file to complete the installation.

 cuda installation

When installing cuda, the temporary decompression directory will be set for the first time, and the installation directory will be set for the second time;

Temporary decompression path, it is recommended to default, or you can customize it. After the installation is complete, the temporary decompression folder will be automatically deleted;

The installation directory is recommended to be the default;

Note: The temporary decompression directory should not be set the same as the cuda installation path, otherwise the installation directory will not be found after the installation is complete! Here I set the temporary installation directory to a non-system disk path, but be careful to select an empty folder, otherwise an error will be reported.

choose custom install

After the installation is complete, configure the environment variables of cuda;

In the command line, test whether the installation is successful;

Double-click "exe file" and select the download path (the default path is recommended)

 

 

 agree and continue

For custom installation, the simplified version downloads all components and overwrites the original driver, so custom download is recommended here.

If you are installing for the first time, try to select all

If you are installing for the nth time, try to only select the first one, otherwise an error will occur.

Did not select visual studio, later said that it could not be found, then returned to cancel this check box

 It is not recommended to modify the installation directory here, because many errors in later development come from path problems.

 Ok, click next

Open the control panel and you will find a lot of configuration and driver files installed.

View environment variables

Click Settings --> Search Advanced System Settings --> View Environment Variables

[If you don't need to add it yourself]

 

 There are a total of four system variables, all of which are automatically generated, but sometimes the last two system variables may not be automatically generated, and you need to add them yourself, and pay attention to the path when adding them.

These two variables are placed below for easy copying

NVCUDASAMPLES_ROOT

NVCUDASAMPLES11_0_ROOT

Verify that CUDA is installed successfully:

Win+R key to run cmd, enter nvcc --version to view the version number;

set cuda, you can view the environment variables set by CUDA.

nvcc --version
OR
nvcc -V

set cuda

 At this point, the CUDA installation has been successful, but the assistance of cuDNN is needed to complete the tensor acceleration operation, so install cuDNN below.

cuDNN download and installation

cuDNN download

The cuDNN address is as follows, but it should be noted that we need to register an account before we can enter the download interface. You can register with confidence.

cuDNN Download | NVIDIA Developer

Click to register

 After successful registration, the interface is as follows:

 Use the URL below to view the adapted cuDNN

cuDNN Archive | NVIDIA Developer

Choose the cudnn version that matches your cuda version. Here I installed CUDA10.1, so I choose the following version:

 The download result is a compressed package

 cuDNN configuration

The configuration of cuDNN is more accurate. We first decompress the downloaded cuDNN, and we will get the following files:

Unzipped files:

After downloading, I found that cudnn is not an exe file, but a compressed package. After decompression, there are three folders. Copy the three folders to the cuda installation directory.

The installation path of CUDA is shown in the previous screenshot, or open the environment variables of the computer to view, the default installation path is as follows:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

When copying, you can see that in the CUDA installation directory, there is a folder with the same name as the decompressed cuDNN. Note here, don’t worry, just copy it directly. The configuration files in the folder with the same name after decompression of cuDNN will be added to the folder with the same name in the CUDA installation directory. [It is still recommended to copy the contents of the folders to the corresponding folders here]

cuDNN is actually a patch of CUDA optimized for deep learning operations. Then add the environment variable

 Add to system variables:

Add the following path to the path in the system environment variable (modify according to your own path)

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp

Verify that the configuration was successful

After the configuration is complete, we can verify whether the configuration is successful, mainly using CUDA's built-in deviceQuery.exe and bandwidthTest.exe:

First win+R to start cmd, cd to ...\extras\demo_suite in the installation directory, and then execute bandwidthTest.exe and deviceQuery.exe respectively (you need to enter "bandwidthTest.exe" and "deviceQuery.exe" directly after entering the directory), Get the following picture:

Finally, what I want to say is that CUDA is a very torturous program. Not only will there be version or other weird errors during installation, but also various errors will appear during the later code running and development process. Such a mistake, so I wish you all a good installation, and less bugs in the later period.

Finally, ask for a reward, and will continue to output high-quality content.

 Referenced from

(1136 messages) CUDA installation tutorial (super detailed)_Billie's Blog-CSDN Blog

(1136 messages) cuda installation tutorial + cudnn installation tutorial_hw@c14h10's blog-CSDN blog_cudnn 

(1136 messages) [CUDA] cuda installation (windows version)_Hewei xl's blog-CSDN blog_cuda windows

 (1136 messages) CUDA installation tutorial_Ziyu Linmu's blog-CSDN blog_cuda installation

(1136 messages) CUDA installation tutorial under Windows10 system, Xiaobai tutorial! Very detailed! ! _A small blog-CSDN blog_windows10 install cuda 

Guess you like

Origin blog.csdn.net/anmin8888/article/details/127910084