pytorch installation: simple and easy version

        In order to learn deep learning, we need to install the pytorch framework, but running the command directly on the official website often fails to install successfully. Therefore, here is a simple and easy installation method with high installation feasibility.

1. Environmental requirements: Anaconda

        1. If it is not installed, you need to download and install it from the Anaconda official website: Anaconda | The World's Most Popular Data Science Platform

        2. I have already installed cuda before, but installing pytorch will automatically install the corresponding version, which can be skipped. If you want to install CUDA, you can refer to my blog: Simple tutorial for installing CUDA in windows_Qianmengyu 11's blog-CSDN blog

2. Select and download the corresponding version of whl:

        We need to know that the main reason why directly using the pytorch official website command is unsuccessful is that the computer may not match, so we have to choose the appropriate whl to install directly according to our own cuda restrictions and python version, and we can basically install it successfully.

        2.1 python version:

        We open Anaconda Prompt and enter:

python -V

         You can check the python version configured in the Anaconda environment at this time. For example, the version in this article is 3.7.4:

        2.2 cuda version:

         Open the NVIDIA control panel and click Help->System Information->Components to view the highest installable CUDA version:

 

        From the picture we can see that the cuda of this computer can be installed up to version 10.1.

        2.3 pytorch version selection:

        We can get the corresponding optional pytorch version according to the cuda version, and the relationship is roughly as follows:

CUDA Toolkit version PyTorch version
9.2 1.2.0,1.3.0,1.3.1,1.4.0,1.5.0,1.5.1,1.6.0,1.7.0,1.7.1
10.0 1.3.0 ,1.3.1,1.4.1
10.1 1.5.0,1.5.1,1.6.0,1.7.0,1.7.1,1.8.0,1.8.1
10.2 1.8.1,1.9.0,1.9.1,1.10.0,1.10.1,1.10.2,1.11.0,1.12.0,1.12.1
11.0 1.7.0,1.7.1
11.1 1.8.0,1.8.1,1.9.0,1.9.1,1.10.0,1.10.1,1.10.2
11.3 1.10.0,1.10.1,1.10.2,1.11.0,1.12.0,1.12.1
11.5 1.11.0
11.6 1.12.0,1.12.1

        For our 10.1 CUDA, you can choose the highest version 1.8.1. Of course, this is just a rough estimate. We will have to see if we can find the corresponding installation whl file in the library later.

        2.4 Download whl file:

        1. Enter the URL: https://download.pytorch.org/whl/cu101

        2. Click torch to enter and find the appropriate whl file based on the python version and cuda version we determined.

        Among them, the one after cu represents the cuda version, for example, cuda10.1 is written as cu101; cp represents the python version, for example, the python of 3.7.x is written as cp37; select the linux or windows system after.

        Our 3.7.1 python and 10.1 cuda should choose: torch-1.8.1+cu101-cp37-cp37m-win_amd64.whl

         Click to download the required version.

3. Install the whl file of pytorch:

        After we download the whl file of the appropriate version, open Anaconda Prompt and enter:

pip install 地址/torch-1.8.1+cu101-cp37-cp37m-win_amd64.whl

        Just modify the path and file name of the downloaded whl file. Our running effect is:

         At this point we have completed the installation of pytorch.

        Open the programming software to verify:

import torch
print("OK!")

        The result is:

         The pytorch installation is completed.

Guess you like

Origin blog.csdn.net/weixin_43907136/article/details/127016646