Berofe installing pytorch, you must first ensure that the following environments are configured on your computer.
Environment(win10):
Python version 3.7.1
Anaconda navigator 1.9.6
CUDA 10.0
Install pytorch according to the official website
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
Supplementary note
When you install using the above method, you will find a serious problem that the pytorch installation is extremely slow. Luckly, We can utilize the mirrors of tsinghua.
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 --set show_channel_urls yes
Then:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
Last:
conda install pytorch torchvision cudatoolkit=10.0
Test
>>>import torch
>>>import torchvision
>>>print(torch.cuda.is_available())
True
>>>
If the result is True, the GPU installation of Pytorch is successful.