Pytorch installation under Windows7 x64 system
- 1. Environmental preparation
-
- 1.1 Check the computer GPU, make sure the graphics card driver has been installed, and the computing power of CUDA supported
- 1.2 Confirm that CUDA, cudnn, and Visual C++ generation tools 2019 have been installed
- 1.3 Make sure that Conda is installed and the Channels address is configured with Tsinghua source mirroring
- 2. Pytorch installation
- 3. Test whether the GPU version of Pytorch is installed successfully
1. Environmental preparation
For specific operations, please refer to section 4.3.9 of my blog Windows 7 to build a TensorFlow deep learning framework (2020.11.22) . The default environment is based on this section.
1.1 Check the computer GPU, make sure the graphics card driver has been installed, and the computing power of CUDA supported
|
|
|
|
1.2 Confirm that CUDA, cudnn, and Visual C++ generation tools 2019 have been installed
In order to install tensorflow-gpu 2.3.1 before, I chose MSVC 2019–vc_redist.x64.exe , CUDA 10.1 , cudnn7.6.5 . Of course, in order to use GPU to run deep learning code, the CUDA and cudnn versions can be supported according to their own graphics card. CUDA computing power to choose.
After downloading and decompressing cuDNN, there are three folders bin, include, lib\x64 in a cuda folder. The files in these three folders (cudnn64_7.dll, cudnn.h, cudnn.lib) need to be copied to the CUDA installation directory Corresponding to the folder.
1.3 Make sure that Conda is installed and the Channels address is configured with Tsinghua source mirroring
2. Pytorch installation
Win+R open the cmd window, enter the command: nvcc -V
view the CUDA version and the compiler driver
cmd, continue to enter the command: conda create --n jjgpytorch python=3.6 //创建名称为jjgpytorch的虚拟环境
then you need to enter the whl package website of Pytorch to download the cu101/torch-1.4.0-cp36-cp36m-win_amd64.whl file, copied to the D: \ Anaconda3 \ envs \ jjgpytorch \ Scripts folder
in the folder window open cmd, and then if direct input pip install torch-1.4.0-cp36-cp36m-win_amd64.whl
to install Pytorch, then you may be prompted numpy.core.multiarray failed the to Import , and therefore need to install numpy Then install torch.
pip install numpy
pip install torch-1.4.0-cp36-cp36m-win_amd64.whl
In the above picture, it prompts us to successfully install torch-1.4.0, and then there is a warning message, prompting that the directory D:\Anaconda3\envs\jjgpytorch\Scripts where the two exe files are located needs to be placed under the system environment variable Path, and add below .
View the installed packages in the jjgpytorch environment:
conda activate jjgpytorch
pip list
3. Test whether the GPU version of Pytorch is installed successfully
Verification code:
import torch
x = torch.rand(5,5)
print(x)
torch..cuda.is_available() #如果返回True,GPU版Pytorch成功安装完毕