当前位置:网站首页>Yolov5 advanced 5 GPU environment setup

Yolov5 advanced 5 GPU environment setup

2022-06-26 09:00:00 Parity nonconservative 4.0

I'm familiar yolov5 Of CPU Environmental Science , The next step is to build GPU The environment . from yolov2 tensorflow keras darknet, The original GPU Building is very cumbersome , It's not just about cuda and cudnn Corresponding , It should be completely consistent with the driver version , More in windows Environment sets a large number of environment variables and paths , This is a very imperfect solution . Now? yolov5 pytorch This problem no longer exists , It can be said that it can be completed with one click in the activation environment GPU Construction of environment .
First of all, check Your own graphics card supports cuda edition , Because the test I do with my notebook now , The graphics card tested is MX230, Don't laugh , The training speed has been significantly improved .
Right click on the desktop nvidia panel see cuda
 Insert picture description here
Now my reality is 11.7, In fact, before I upgraded the driver, I was 10.0. If you want to support the new Cuda edition , Please go nvidia Download the new driver on the official website , Don't worry that this driver is backward compatible , You just need to install Support below cuda11.7 Of pytorch, In fact, when I posted this article ,pytorch Only to 11.3.
After upgrading the driver , Follow the previous steps to create an isolated environment , in the future cuda cudnn And so on , There is no need to modify the environment variables , I am very tired of the process of changing environment variables .
 Insert picture description here
If there are still problems in building the environment and creating separate folders , You can read the first article yolov5 Environment quickly created articles
https://blog.csdn.net/buaaweibin/article/details/125356544?spm=1001.2014.3001.5502

Open below pytorch Website
 Insert picture description here
You can choose 11.0 edition , But the front cpu It was said during the test 11.0 Compatibility is not good , There will be a path error prompt after the training . I suggest 1.8.0 edition , Of course 9 10 Version can also test the following .
Go to the previous version page .
You can see , There are basically two methods for online installation
One is conda One is pip
 Insert picture description here
 Insert picture description here
conda Method support to cuda 11.3 pip Support to 11.1 The two methods pytorch Same version , Corresponding torchvision torchaudio The version of is also slightly different . But there is no problem installing according to the corresponding version .
It's starting to work conda For installation cuda 11.3

conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge

The results are installed in pytorch1.10 when ( Or other versions ) Very slow , Need about 2 In hours or so .

I used pip edition

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

from pytorch Official website installation , Very fast ,2 Finish loading in minutes , After that, you may be prompted that some dependencies are not installed , It doesn't matter. We can test it first pytorch and GPU
 Insert picture description here
It shocked me ,gpu The environment has been built , In fact, it can be found during installation , Installed version pytorch It's with cuda and cudnn Of .

The following routine is the same as before , hold yolov5-master decompression ( The previous image has been unzipped ), Then install dependencies in the current directory

pip install -r requirements.txt

After installation , The environment is set up , Let's test first coco128 Data set training , Get into yolov5-master Folder , perform

python train.py --img 640 --batch 16 --epochs 5 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml --weights yolov5s.pt

There is an error , The page file is too small
 Insert picture description here
because cpu There are no mistakes in training , It can be associated with GPU The existing is too small , Can reduce batch solve

python train.py --img 640 --batch 2 --epochs 5 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml --weights yolov5s.pt

Start training , Correctly identify GPU
 Insert picture description here
During the training, you can see gpu Video memory usage , monitor cpu You can find cpu Very low occupancy
 Insert picture description here
At the same time, the speed has increased a lot , All in all, only 4 minute .CPU Training should be 20 Minutes or more .
Use the low-end graphics card to complete gpu I didn't have much hope for it , The following research will rely on GTX1070 8G and RTX2060s 8G Graphics card to complete , We'll see .

原网站

版权声明
本文为[Parity nonconservative 4.0]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260832344371.html