Use Anaconda to install Pytorch1.13.0 GPU environment (CUDA11.6 brain-residual version)

In the first half of the semester, the CPU version of the small model has been running enough to use. At that time, I also tried to install the GPU version many times. But now it seems powerless to run the detection model CPU, so I decided to try to install the GPU version painfully. The installation environment is the most troublesome thing for all people who learn AI in the early stage. This article is the brain-dead map of installing the Pytorch GPU version.

PyTorch official website: https://pytorch.org/


premise

It is best to have Anaconda installed, and check the NVIDIA GPU computing power of your computer in advance
GPU computing power query
insert image description here


提示:以下是本篇文章正文内容,下面案例可供参考

1. Check the cuda version

1. Right-click on the NVIDIA control panel
insert image description here
2. Click on the system information in the lower left corner
insert image description here
3. Click on the component to view the NVIDIA CUDA version
insert image description here

2. Create a virtual environment

  • 0. First go to the pytorch official website to check the torchvision version corresponding to different pytorch versions
    Portal: https://pytorch.org/get-started/previous-versions/
    提示:考虑到稳定性我选择了1.12.0版本的Pytorch,可以根据复现的论文代码的要求下载不同的版本
    insert image description here

  • 1. Create a virtual environment named torch1.12 here, python uses version 3.8

conda create -n torch1.12 python=3.8
  • 2. Activate the virtual environment (Note: Subsequent operations are performed under this virtual environment)
conda activate torch1.12

3. Install GPU offline

Since I used the online installation method before, and then I couldn’t install it all the time, and I reported an error halfway through. This time I tried the offline installation method, torchand torchvisionthe download address of the (torch environment) file
1. Download: https://download .pytorch.org/whl/torch_stable.html

Divided into linux and win systems, the installation method is the same
insert image description here

Download the required torch and torchvision two files to download. Note that cp38 represents the compilation environment of python3.8, and win_amd64 represents the 64-bit win operating system. cu116 is the version corresponding to cuda11.6.

2. After the download is complete, we put these two files into a 中文可能路径解析出错folder with the full path in English ( ).

insert image description here

3. After entering the virtual environment just created with conda, switch to torchand install the whl package in torchvisiontwo order:文件目录下

pip install torch-1.12.0+cu116-cp38-cp38-win_amd64.whl
pip install torchvision-0.13.0+cu116-cp38-cp38-win_amd64.whl

insert image description here
4. Check whether the installation is successful

import torch
torch.__version__

insert image description here

4. Run the code (configure the virtual environment in the IDE)

  1. Click file–>setting
    insert image description here

insert image description here
3.
insert image description here
4. Select parser
insert image description here

I tested the previous classification network, and there is not much data. Before the CPU ran a model for two hours, the GPU only took ten minutes! ! !

The following is a Fast-RCNN network model with resnet50 as the backbone trained on the VOC dataset using GPU.
insert image description here

Guess you like

Origin blog.csdn.net/qq_45973897/article/details/130259533