[2023 latest plan] Install CUDA, cuDNN, Pytorch GPU version and solve the problems such as torch.cuda.is_available() returning false

1. Install CUDA

1.1 Check if CUDA is installed

        Shortcut key win+r, enter cmd, enter nvcc -V in the command line to view the version information

        If it is already installed, the version information will be displayed, please skip to the second step

1.2 If it is not installed, please search and open the NVIDIA control panel in the lower left corner

        Click System Information to enter the component page to view the version of CUDA

 

       As shown in the figure, the CUDA version of the author's computer is 11.7, so choose to download CUDA ≤ 11.7 version

       Enter the official website CUDA Toolkit Archive | NVIDIA Developer CUDA Toolkit Archive | NVIDIA Developer  , download the corresponding version of CUDA CUDA Toolkit Archive | NVIDIA Developer 

          The version depends on the individual situation, do not pursue a higher version of CUDA than your own

        After the download is complete, you will get an .exe installer, double-click to open it and go to the next step. It is recommended to install the default path . If you have any questions about this step, you can check this article:

(133 messages) Detailed tutorials for installing CUDA, cuDNN, and Pytorch in one go! _torch==1.7.1+cu101_Nefu_lyh's Blog - CSDN Blog

        Use the shortcut key win+r, enter cmd, and enter nvcc -V in the command line to check whether CUDA is installed successfully. If it is installed, the version information will be displayed

 2. Install cuDNN

        Enter the official website https://developer.nvidia.com/rdp/cudnn-download  , first register and log in, and check your CUDA version number corresponding to your own cuDNN (the CUDA and cuDNN version comparison table used to be required, but now Nvidia only provides two versions cuDNN, corresponding to CUDA 12.x and CUDA 11.x respectively)

         

         After downloading the compressed package, decompress it and change the file name to cudnn

         Copy the cudnn file and paste it to the root directory of C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7

         Finally, configure the environment variable of the system Path

 

 

 

         These two sentences are actually the directory where the lib64 and bin files are stored in the cudnn folder just renamed, pay attention to the version number when copying and pasting

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\extras\CUPTI\lib64

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\cudnn\bin

3. Install Pytorch

        Enter the official website Start Locally | PyTorch , select the version of Pytorch according to the CUDA version installed in the first step

        Through the shortcut key win+r, enter cmd, enter the following paragraph in the command line, download Pytorch

         Note: The author tried many times, but the download failed. In addition, the method of other authors to download dependencies from the network disk by parsing the link address is outdated, so we adopt another universal method

        We enter the link provided by this pip (according to the actual situation), which is the Pytorch dependent download page

        We need to download torch, torchaudio, torchvision

 3.1 Download torch

         Click the torch link, search for the required .whl file according to the python version and CUDA version crtl+f search

         cu117 means CUDA version 11.7 cp39 means python version 3.9

         As you can see, there are two official versions of torch-1.13.0 and 1.13.1, choose one (recommended to choose the smaller one), and then choose win or linux according to the operating system

        Because the author's computer has python 3.9 CUDA 11.7 win operating system, the following .whl files are downloaded

 3.2 download torchaudio

         Similarly, choose the appropriate version

 

 3.3 Download torchvision

         Similarly, choose the appropriate version

 

 

 3.4 Installation files

        Store the above files in a folder, enter cmd in the directory box, and enter the console

         Enter the paragraph that pip did not download successfully before

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117

4.0 test

         Enter the following codes in sequence from the console, if True appears, the installation is successful!

import torch
torch.__version__
torch.cuda.is_available()

Referenced articles (workaround and installation content sections are outdated):

(133 messages) Detailed tutorials for installing CUDA, cuDNN, and Pytorch in one go! _torch==1.7.1+cu101_Nefu_lyh's Blog - CSDN Blog

(133 messages) torch.cuda.is_available() returns false - solution_Nefu_lyh's Blog-CSDN Blog

(133 messages) CUDA 11.7 cannot install the GPU version of pytorch_cuda11.7 corresponds to pytorch_dy_______'s blog-CSDN Blog

Guess you like

Origin blog.csdn.net/Next_SummerAgain/article/details/129463931