欢迎光临散文网 会员登陆 & 注册

部署YOLOV5环境到服务器进行多GPU训练

2023-06-09 22:57 作者:蚂蚁资源  | 我要投稿

# 部署YOLOV5环境到服务器进行多GPU训练


### 访问官网进行注册并登录

[点我访问AutoDl官网](https://www.autodl.com/home)

#### 购买一台GPU服务器:

![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/1.png)


### 通过vscode链接GPU服务器:

#### 安装插件

![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/2.png)


#### 配置连接信息

![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/3.gif)


### 安装服务器中的YOLOV5-GPU环境

#### 到torch官网:

[点我访问torch官网](https://pytorch.org/get-started/locally/)

![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/4.png)


#### 复制命令到终端,安装pytorch,记得把pip3改为pip

```

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

```


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/5.png)


#### 最后等待安装完成即可


### 复制自己本机跑通的YOLOV5代码到服务器


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/6.gif)


#### 注释这里我们通过vscode进行上传文件,也可以通过其他方式进行上传


#### 先解压文件


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/7.png)


#### 进入yolov5-7.0文件夹根目录将tqdm>=4.64.0改为tqdm>=4.63.1输入以下命令:

```

pip install -r requirements.txt

```


### 在服务器中安装python扩展


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/8.png)


### 重连服务器,重新打开目录yolov5目录准备训练


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/9.gif)


#### 如果出现Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...:

```

多等一会或者多运行几次即可,实在不行可以手动在本地找到这个字体文件复制到服务器中的/root/.config/Ultralytics/目录下

```


### 因为代码我们在本地已经跑通了,所以直接运行train.py即可进行默认单GPU训练:


![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/10.gif)


### 如果你需要进行多GPU训练,可以参考以下步骤,前提是你真的买了两个GPU哦:

![](https://img.antszy.com/imgs/antszy.com/分享/Python/部署YOLOV5环境到服务器进行多GPU训练/11.png)


#### 既然是多GPU就要合理调试batch-size中的值,可以适当微调,观察显卡显存,如果显存没满可以持续增加batch-size,默认训练epochs的值是100,如果你数据足够多,可以搞500epochs,当然了多GPU训练请先确保你的数据有5000-30000数据再使用。


### 好了本期教学分享到这里


部署YOLOV5环境到服务器进行多GPU训练的评论 (共 条)

分享到微博请遵守国家法律