GPU version of PyTorch corresponding installation tutorial

1. Before correctly installing the corresponding GPU version of PyTorch that matches your computer, you need to understand three basic concepts

Computing power, CUDA driver version, CUDA runtime version

①Computing power: You need to know your graphics card first, and then correspond to it according to the official website form to get the computing power

insert image description here

②CUDA driver version: the hardware driver of the graphics card on the computer

insert image description here

③CUDA runtime version: CUDA version number displayed on pytorch official website

insert image description here

The relationship between the three needs to be satisfied:
CUDA driver version ≥ CUDA runtime version (ie: ②≥③)
CUDA runtime version must support the computing power corresponding to the GPU of your computer (ie: ② must support ①)

Second, check the GPU model of your computer

Shortcut key: Ctrl + Shift + Esc
For example, mine is: NVIDIA GeForce GT 640M
insert image description here
It is recommended to install the latest version of the graphics card driver before this, the official website driver download link
insert image description here

3. Conversion computing power

Computing power comparison table on the official website
The official website needs to go over the wall, here is a portal: NVIDIA graphics card computing power query
My here is a computing power of 3.0 , (the 2008 Olympic limited computer hahahaha)
insert image description here

4. Determine the computing power supported by the CUDA version

Portal: the computing power supported by different versions of CUDA
. This is the computing power of 3.0 , corresponding to the CUDA runtime version 9.0-9.2 and 10.0-10.2 .
insert image description here

5. Check your CUDA driver version

win+R , enter cmd , open the command window, enter nvidia-smi
here I am 10.1
insert image description here
( 10.1 ) this is the CUDA driver version, the value should be greater than the CUDA runtime version ( 9.0-9.2 and 10.0-10.2 )
for final screening, CUDA runtime version It can be 9.0, 9.1, 9.2, 10.0, 10.1. To be on the safe side, just choose 10.0 here.

6. Install your own GPU version of pytorch online

On the pytorch official website , find CUDA 10.0 to install
because my computer is relatively old, and then choose the previous version of CUDA to download and install
insert image description here
insert image description here

Because my computer's computing power is only 3.0, torch v1.3 will no longer support GPUs with a computing power below 3.5

CUDA runtime version 10.0 Find a lower torch version, for example, pytorch is v1.2.0 , because it is installed by Conda, and the final command is: here
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
is -cthe meaning of the download channel, -c pytorchwhich means downloading from the official website of pytorch, because it is a foreign country The server, generally will be very slow. We can see that this command actually downloaded three libraries, pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0

①Online download

Download from Tsinghua source (pytorch and torchvision are one address, cudatoolkit is another address)

conda install pytorch==1.2.0 torchvision==0.4.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/ 

conda install cudatoolkit=10.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

Possible error reporting problems

Just enter the command in your own environment space
If the following problems occur: CondaHTTPError: HTTP 403 FORBIDDEN for url
insert image description here

try a solution

The best way is to do it in the morning, family members, especially after 6 o'clock in the morning, the Internet speed is soaring! ! ! ! Download timeout errors like this can generally be resolved!

Reset the configuration file: conda config --remove-key channels
Add Tsinghua source:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
insert image description here
just run it again after that.
You can also refer to the blog post: Is the download speed slow in Anaconda?

②Local installation of PyTroch

If there is always a problem with the online installation, it may be that the
server response timed out, then you can directly
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
download and install it locally Portal

cu100:CUDA10.0
cp36:python3.6版本It needs to be consistent with the direct python version number.
找到对应的windows64位进行下载即可
Find torch==1.2.0 and torchvision=0.4.0 . The python version can be downloaded according to the actual situation.
insert image description here

insert image description here

After the download is complete, enter the following command in the environment space to install locally.
pip install D:\desktop\torch-1.2.0-cp36-cp36m-win_amd64.whl
Among them, D:\desktop\torch-1.2.0-cp36-cp36m-win_amd64.whl is the download path, this is to install torch-1.2.0
insert image description here
and then install it torchvision0.4.0
pip install D:\desktop\torchvision-0.4.0-cp36-cp36m-win_amd64.whl
insert image description here

7. Verification

Enter the following commands one by one in the environment space.
python
import torch
torch.cuda.is_available()
If it returns True, it means that the GPU is successfully installed
quit()and exits the editor.
insert image description here

End~~ Flowers~~

Guess you like

Origin blog.csdn.net/qq_41264055/article/details/132092447