Install Pytorch on Windows 7 64-bit system (2020.12.27)

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

Computer GPU
Graphics card driver is installed
NVIDIA Control Panel
Graphics card CUDA computing power
        Since the computer’s GPU graphics card is GTX 970, confirm that the **graphic card driver** is installed, you can go to [NVIDIA official website](https://developer.nvidia.com/zh-cn/cuda-gpus) to view the computer graphics card CUDA computing power is 5.2:

1.2 Confirm that CUDA, cudnn, and Visual C++ generation tools 2019 have been installed

Insert picture description here
        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.
Insert picture description here
Insert picture description here

Insert picture description here
        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

Insert picture description here

2. Pytorch installation

        Win+R open the cmd window, enter the command: nvcc -Vview the CUDA version and the compiler driver
Insert picture description here
        cmd, continue to enter the command: conda create --n jjgpytorch python=3.6 //创建名称为jjgpytorch的虚拟环境
Insert picture description here
        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
Insert picture description here
        in the folder window open cmd, and then if direct input pip install torch-1.4.0-cp36-cp36m-win_amd64.whlto 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

Insert picture description here
        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 .
Insert picture description here
Insert picture description here
View the installed packages in the jjgpytorch environment:

conda activate jjgpytorch
pip list

Insert picture description here

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成功安装完毕

3.1 cmd window operation

Insert picture description here

3.2 Jupyter Notebook operation

Insert picture description here

3.3 Spyder operation

Insert picture description here

3.4 PyCharm running

Insert picture description here

Guess you like

Origin blog.csdn.net/jing_zhong/article/details/111822940