The fastest and easiest Python installation tutorial for Pytorch (detailed graphic and text)

Many of the papers in the past two years are in the Pytorch environment, so here is a summary of the Pytorch installation tutorials, and the fastest, easiest, and best way to complete the installation. Like to remember to collect, like, and follow.

native environment
Win10+1050Ti+Python3.7

Technical Q&A

This method comes from the sharing of small partners in the technical group. If you want to join, follow the steps below

At present, a technical exchange group has been opened, and the group has more than 3,000 people. The best way to remark when adding is: source + interest direction, which is convenient to find like-minded friends

Method ①, add WeChat ID: dkl88191, remarks: from CSDN + technical exchange
Method ②, WeChat search public number: Python learning and data mining, background reply: add group + CSDN

1. Check the CUDA version of the machine

cmd command line input nvidia-smi, you can see the version number of CUDA on the far right of the first line, my version is 11.1

insert image description here

2. Install Pytroch


1. Click to enter Pytorch official website

insert image description here
Then select Get Started, which is the following interface
insert image description here

2. Here is the choice of Pytorch version. First, I choose the Stable version, then the OS is Windows system, the Package package uses Conda, Language must choose Python, and the final Compute Platform is determined according to your needs.

If you want to run the code on your own computer (with NVIDIA graphics card), choose CUDA. If you don't need to run on your own computer (run on a server) or don't have a discrete graphics card, choose CPU.

We have already seen the CUDA version of our own NAVIDA in the first step, here we must choose a CUDA version lower than our own. For example, if my version is 11.1, then I can only choose 10.2, because 11.3 is a bit high. For the same reason, basically everyone can choose 10.2.

If you don't have anaconda installed, you need to install it

If you want to install Pytorch through pip, I can tell you that it is almost impossible to install through pip, and it takes far more time than installing anaconda. Therefore, I will help you detect this detour first, don't step on it again, anaconda It is really a must-have for deep learning.

insert image description here

3. Then copy the command line statement at the bottom, open the anaconda command line, first enter the environment where you need to install Pytorch, and then run it.

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

insert image description here

4. You can see that there are Pytorch and cudatoolkit in the package to be installed, we enter y to confirm, and then press Enter

insert image description here

5. Now wait for these packages to be successfully installed. You can see that Pytorch is still relatively large, so wait patiently.

insert image description here

6. After the installation is complete, the message done will be prompted.

insert image description here

7. Enter pip list to see if our package is installed. Here you can see that torch-related packages are installed.

insert image description here

8. We enter pythoninto the Python environment, and then enter import torch, if no error is reported, the import can be successful.

insert image description here

9. Enter to torch.cuda.is_available()see if the torch can use the graphics card, True means yes!

insert image description here

CUDA (Compute Unified Device Architecture) is a computing platform launched by the graphics card manufacturer NVIDIA. CUDA™ is a general-purpose parallel computing architecture introduced by NVIDIA that enables GPUs to solve complex computing problems. It contains the CUDA instruction set architecture (ISA) and the parallel computing engine inside the GPU. Developers can use the C language to write programs for the CUDA™ architecture that run at ultra-high performance on CUDA™-enabled processors.

Supongo que te gusta

Origin blog.csdn.net/m0_59596937/article/details/127180446
Recomendado
Clasificación