mmdetectionv2.8 踩坑

以下是自己配置v2.8遇到的一些问题 

mmdetv2.8今天首次尝试遇到的问题
1.最新版v2.8使用mmcv-full,不再是mmcv
2.mmcv-full现在修改为与CUDA和pytorch具备对应性,版本安错了也不行
3.我的环境是cuda10.0 torch1.4.0 在其官方的下载地址上,没有该文件
https://download.openmmlab.com/mmcv/dist/cu100/torch1.4.0/index.html
里面没有mmdetv2.8用到的mmcv==1.2.4
强行安装会一直卡在 
Building wheels for collected packages: mmcv-full
Running setup.py bdist_wheel for mmcv-full ... /
4.遇到这种情况需要clone mmcv 自己编译
但是会很麻烦,需要onnxruntime-linux-x64-1.5.1.tgz,然后配置,重新编译mmcv
5.最后不想踩坑,正在换cuda10.1 pytorch1.5 or pytorch1.6 去安装mmcv-full==1.2.4,正在下载,如果还有坑,再补上
https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html

 

mmdetection从入门到放弃的体验:

分布式训练指定显卡方式如下
不可行方案:
CUDA_VISIBLE_DIVICES=3,4,5 ./tools/dist_train.sh configs/faster_rcnn/nut2_faster_rcnn_r50_fpn_1x_coco.py 3
./tools/dist_train.sh configs/faster_rcnn/nut2_faster_rcnn_r50_fpn_1x_coco.py 3 --gpu-ids 3 4 5

可行方案:
import os
os.environ['CUDA_VISIBLE_DEVICES']='3,4,5'
加入到了tools/train.py中
使用
./tools/dist_train.sh configs/faster_rcnn/nut2_faster_rcnn_r50_fpn_1x_coco.py 3


非分布式方法,无法多张显卡(内部写死了,和以前不一样)
AssertionError: MMDataParallel only supports single GPU training, if you need to train with multiple GPUs, please use MMDistributedDataParallelinstead

除了和以前一样,需要修改num_classes=4,还需要配置文件,数据集需要在外部指明自定义coco类别
否则会出现bug:
ValueError: need at least one array to concatenate

修改如下:
CLASSES = ('nut', 'wires_x', 'dustproof', 'gate_nut')
dataset_type = 'CocoDataset'
data = dict(
    samples_per_gpu=1,
    workers_per_gpu=1,
    train=dict(
        type=dataset_type,
        classes = CLASSES,
        ......)
    val=dict(
        type=dataset_type,
        classes = CLASSES,
        ......)
    test=dict(
        type=dataset_type,
        classes = CLASSES,
        ......)

提醒
在v2.8版本,可用python tools/print_config.py configs/faster_rcnn/nut2_faster_rcnn_r50_fpn_1x_coco.py
将最新版本的config展开打印,这样就可以方便修改和查看自己有哪些写错了或者没考虑到

python tools/print_config.py configs/faster_rcnn/nut2_faster_rcnn_r50_fpn_1x_coco.py > new_configs.py
将第一行删除就可直接使用

但是v2.9(最新版本)这个文件不见了,可能又修改了项目文件结构

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值