R3Det代码复现

本文详细记录了在RTX3090显卡上使用mmdetection框架实现R3DET对象检测模型的过程,包括环境配置、代码下载、数据集切割、模型训练以及遇到的错误和解决方案,如适配pytorch和cuda版本、处理训练中断和内存溢出问题。
摘要由CSDN通过智能技术生成

mmdetection采坑实记(r3det)

前言

代码链接:GitHub - SJTU-Thinklab-Det/r3det-pytorch: R3Det based on mmdet 2.19.0

论文链接:https://arxiv.org/abs/1908.05612

显卡:RTX3090

一、创建环境

conda create -n mmdetection python=3.7#conda create -n 环境名 python=版本
conda activate mmdetection 
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forg

二、配置R3DET

1.下载代码文件

git clone https://github.com/SJTU-Thinklab-Det/r3det-pytorch.git --recursive
cd mmdetection

2.安装mmcv-full

#使用以下命令查看 CUDA 和 PyTorch 的版本
python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'
#官网https://mmcv.readthedocs.io/zh_CN/latest/get_started/installation.html查看mmcv-full版本
pip install mmcv-full==1.4.8 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8/index.html

3.安装r3det

pip install mmdet==2.19.0
pip install -r requirements.txt
pip install -v -e . #成功显示Successfully installed r3det-0.1.0

三、切割数据集

由于我运行的是dotav1.0的数据集,切割将原始图像裁剪成1024×1024个重叠200的补丁。

1.修改路径

./tools/split/split_configs/dota1_0/ss_train.json
./tools/split/split_configs/dota1_0/ss_val.json
./tools/split/split_configs/dota1_0/ss_test.json

2.切割

python tools/split/img_split.py --base_json tools/split/split_configs/dota1_0/ss_train.json
python tools/split/img_split.py --base_json tools/split/split_configs/dota1_0/ss_val.json
python tools/split/img_split.py --base_json tools/split/split_configs/dota1_0/ss_trest.json

四、训练

CUDA_VISIBLE_DEVICES=0 PORT=29500 ./tools/dist_train.sh configs/rretinanet/rretinanet_obb_r50_fpn_1x_dota_v3.py 1

五、error处理

1.运行pip install -v -e .报错,报错信息如下

在这里插入图片描述
解决方法是:pytorch cuda mmcv-full 之间的对应关系,一定要适配
在这里插入图片描述
pytorch和cuda版本
在这里插入图片描述

这是运行成功的一项配置。

torch官网:https://pytorch.org/
mmcv-full下载官网:https://mmcv.readthedocs.io/zh_CN/latest/get_started/installation.html
查看pytorch和cuda版本代码:python -c ‘import torch;print(torch.version);print(torch.version.cuda)’

  • 暴力解决:重新搭建环境,配置版本*

2.训练过程戛然而止

在这里插入图片描述
解决办法:因为我用的是3090的显卡,最低支持的cuda1.11,所以我又重新配置了环境

3.epoch=1的结果

*加粗样式

epoch=12的结果显卡溢出

在这里插入图片描述
内存不足,硬件问题,可以降低batchsize和bbox的数量。

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值