[Details] The method of installing CUDA summarized after groping three times, using GPU to run code in one go

When I installed it for the first time, I was really a novice. I didn’t understand various concepts. I only knew that CUDA needs to be installed to run code using GPU. I took a lot of detours and was abused for a week. The installation was very difficult and confusing;

The second installation was on a classmate's computer, and there were some detours, but this time it only took half a day, and I was very proud of it at the time.

This is the third installation. With the experience of the second time, the installation went very, very smoothly. It can be said that it was done in one go. Sending the process over now is my first CSDN. A little excited.

Brief description of the steps :

1. Make sure you have an Nvidia GPU

2. Upgrade the driver

3. Install CUDA

4. Install GPU version of Pytorch

The key: the version must correspond, and the versions in each place must correspond. It is best to check and confirm versions often.

Detailed process:

1. Confirm that there is a GPU

In Task Manager - Performance, look at the model in GPU1. ( GPU1 is an independent display, GPU0 is an integrated display)

 

2. Upgrade the driver:

Official website download, tutorial can refer to: (51 messages) Windows update NVIDIA graphics driver_nvidia installation chooses graphics driver or graphics driver_Zhenhua OPPO's Blog-CSDN Blog

After that check the version number. In the NVIDIA Control Panel, the version here shows 472.84.

 

3. Install CUDA.

View the corresponding CUDA version:

Just look at this table. (As long as you can find it in the table below, you don’t need to look at the original website: CUDA 12.0 Release Notes — cuda-toolkit-release-notes 12.0 documentation (nvidia.com)

For example, the version 472.84 just now, corresponding to the table, found >=452.39, you can install CUDA11.8x.

Official website download corresponds to CUDA: CUDA Toolkit Archive | NVIDIA Developer

Note that the click matches the version just matched. Here is CUDA11.8.

 After downloading, double-click to install.

Check if the installation was successful:

Enter cmd in the search bar and press Enter (enter cmd), enter nvidia-smi

can be obtained as shown in the figure. The CUDA shown here is 11.8 , which means the installation is successful.

 

4. Install the GPU version of torch. Be sure to download the corresponding version!

Confirm the CUDA model and python version, and download the GPU version of torch from the URL below. (I had a problem with the official website before, I recommend downloading from this website)

(In addition, if you want to check the torch version at this step, you can download torch with pip in python , and then print the version on the terminal, such as x.xx.x+cpu , it means that it is the cpu version of torch . After installing the GPU version of torch , then Repeating this step will display x.xx.x+cu118 )

Go to the URL  https://download.pytorch.org/whl/torch/  to download the gpu version. Look inside carefully, cu118 in the name stands for cuda11.8 , cp39 stands for python3.9. (In addition: the above link only has torch, if you need torchvision or torchaudio, you can find it here: https://download.pytorch.org/whl/ torch_stable.html)

 

After downloading the gpu version of torch , install it with pip in python

 pip install .\torch-1.13.0+cu116-cp39-cp39-win_amd64.whl (note that the name should be replaced with the version just downloaded)

After installation, you can find and view the version installed by torch in the terminal pip list list.

 Finally, in the terminal

import torch,print(torch.__version__),print(torch.version.cuda),print(torch.cuda.is_available())

Display true and you're done~

 

Guess you like

Origin blog.csdn.net/weixin_43614363/article/details/129703133