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 |
Article directory
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
2. Install Pytroch
1. Click to enter Pytorch official website
Then select Get Started, which is the following interface
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.
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
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
5. Now wait for these packages to be successfully installed. You can see that Pytorch is still relatively large, so wait patiently.
6. After the installation is complete, the message done will be prompted.
7. Enter pip list to see if our package is installed. Here you can see that torch-related packages are installed.
8. We enter python
into the Python environment, and then enter import torch
, if no error is reported, the import can be successful.
9. Enter to torch.cuda.is_available()
see if the torch can use the graphics card, True means yes!
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.