This article implements the installation of the GPU version of pytorch under Windows 10. The software used mainly includes: CUDA 10.2 + cuDNN + Anaconda + pytorch1.6.0 + torchvision0.7.0. Here to explain, you can choose the version of pytorch and torchvision that suits you to download and install according to the CUDA you have installed.
For the installation of CUDA and cuDNN, please refer to: Install tensorflow-gpu (2.2.0) installation tutorial under Windows 10 (avoid pit + nanny teaching)
Article Directory
One, whl download
If you use anaconda to install directly, the speed is very slow even if you add Tsinghua source, so we download whl to install it will greatly reduce the time cost.
Download address of various whl of pytorch: https://download.pytorch.org/whl/torch_stable.html
Because my CUDA is version 10.2, I found the whl I need in the cu102 directory, which are
- cu102/torch-1.6.0-cp36-cp36m-win_amd64.whl
- cu102/torchvision-0.7.0-cp36-cp36m-win_amd64.whl
Two, install pytorch1.6.0 + torchvision0.7.0
Open Anaconda Prompt, switch to the path of whl, and enter the following commands in sequence to install it. Because pytorch needs to install the dependent package future first, and torchvision needs to install the dependent package Pillow first, installing it in advance with Tsinghua sources can save time.
For Anaconda related operations, please refer to the Anaconda virtual environment to install Jupyter Notebook and replace the default working directory. Detailed tutorials and usage strategies
# 激活虚拟环境
activate DL
# 切换路径
D:
cd D:\xylfile\study\whl
# pip方式安装
pip install future==0.18.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torch-1.6.0-cp36-cp36m-win_amd64.whl
pip install Pillow == 7.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torchvision-0.7.0-cp36-cp36m-win_amd64.whl
Three, verify whether pytorch can use gpu acceleration
Open the Jupyter Notebook corresponding to the virtual environment for verification
import touch
touch.__version__ # 查看pytorch版本
torch.cuda.is_available() # 判断pytorch是否支持GPU加速
torch.version.cuda # 查看CUDA版本
torch.backends.cudnn.version() # 查看cuDNN版本
torch.cuda.get_device_name(0) # 查看显卡类型
Ending & Easter Eggs
Hello everyone, I am Yi Lei xylbill, a primary school scumbag majoring in Operations Research and Cybernetics at Beijing Jiaotong University. I am very eager to meet excellent friends to exchange and learn together! If you can find the dry goods you need from this article, it is my honor! Finally, please pay attention, like, favorite and comment more! If you have any questions about this article, you can also send me a private message at any time!
Keep self-discipline, be in awe, keep your feet on the ground, and look up at the stars!