Pytorch installation and environment configuration detailed tutorial (CUDA version)


foreword

There are many pitfalls when installing the cuda version of pytorch. There are many versions of pytorch installed online. The general tutorials are to go to the official website of pytorch. Use the URL and mirror source to install. There are many problems. There are also teaching offline installation, but there is no correct installation sequence, the torch version and torchvision version are not compatible, the python version is not compatible with the pytorch version supported by the cuda of your computer, and so on. The following is an installation tutorial that I recorded based on the pits I stepped on.


1. View the CUDA version supported by the GPU

Control Panel - NVDIA Control Panel, click NVDIA Control Panel, the following prompt may appear:
insert image description here
This is because the NVIDIA Display Container LS service is not opened. Open Task Manager and turn it on.
insert image description here
Then click the NVDIA control panel, find the system information in the opened panel, and click Open
insert image description here
insert image description here
to view the highest supported CUDA version of the GPU. The highest supported version of my notebook is 10.0

2. Install CUDA

You can refer to this link: https://blog.csdn.net/Mind_programmonkey/article/details/99688839
is very detailed.


3. Determine torch, torchvision and python versions

Getting here is a very important step . Other tutorials may start to install anaconda here. Don't worry, otherwise it will be easy to step on the pit.
We need to find the corresponding torch and torchvision versions according to the installed CUDA version. In this process, the python version is determined.
First find the torch version we can install in the download link: https://download.pytorch.org/whl/torch_stable.html.

insert image description here
Among them, cu100 is cuda10.0, and cp37 is python version 3.7. Then find the corresponding torchvision version according to the following table.
https://github.com/pytorch/vision#installation

insert image description here
insert image description here
The torchvision version corresponding to the torch1.2 version is 0.4.0. At this time, prepare two whl files by the way.
insert image description here
The reason why you have to choose a good version of python to install is because when you install anaconda later, the problem of python version will be involved. If you blindly install any version of python first, and then download torch and torchvision, you will encounter your own CUDA version The supported python version of torch and torchvision does not match the installed python version.

Fourth, install anaconda

Download address: https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda

According to the python version 3.7 determined above, select the installation file as follows.
insert image description here
Just click next all the way.
insert image description here
After installation, check whether the conda command can be used normally
insert image description here
insert image description here

5. Install torch and torchvision

First build a Python virtual environment to install pytorch, enter in the Anaconda Prompt (miniconda3) command line

conda create -n PyTorchP37 python=3.7

PyTorchP37 is the environment name of your own life. After creating the environment, enter activate PyTorchP37 to enter the virtual environment.
insert image description here
Then switch to the installation directory of the two whl files you just downloaded.

pip install torchvision-0.4.0-cp37-cp37m-win_amd64.whl
pip install torch-1.2.0-cp37-cp37m-win_amd64.whl

insert image description here
insert image description here
After installation, verify the following:

pip install torchvision-0.4.0-cp37-cp37m-win_amd64.whl

insert image description here
If it prints True, the cuda version of Pytorch is successfully installed.

Guess you like

Origin blog.csdn.net/weixin_44901043/article/details/128619718
Recommended