Article Directory
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:
This is because the NVIDIA Display Container LS service is not opened. Open Task Manager and turn it on.
Then click the NVDIA control panel, find the system information in the opened panel, and click Open
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.
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
The torchvision version corresponding to the torch1.2 version is 0.4.0. At this time, prepare two whl files by the way.
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.
Just click next all the way.
After installation, check whether the conda command can be used normally
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.
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
After installation, verify the following:
pip install torchvision-0.4.0-cp37-cp37m-win_amd64.whl
If it prints True, the cuda version of Pytorch is successfully installed.