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的数量。