debug时出现错误: RuntimeError: DataLoader worker (pid(s) 9528, 8320) exited unexpectedly

问题描述:使用mmdetection,用vscode编写代码。直接run程序可以正常运行,但是在debug时出现错误:

RuntimeError: DataLoader worker (pid(s) 9528, 8320) exited unexpectedly

仔细看情况与之是否一致

我的解决方法,找到使用的dataset对应的配置文件。比如我使用的时Pascal VOC数据集,那么在目录:configs/base/datasets/voc0712.py可以找到相应的配置。如果时COCO数据集则要去找其它的配置文件。在configs/base/datasets/voc0712.py中找到:

data = dict(
    # modify here
    samples_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type='RepeatDataset',
        times=3,
        dataset=dict(
            type=dataset_type,
            ann_file=[
                data_root + 'VOC2007/ImageSets/Main/trainval.txt',
                data_root + 'VOC2012/ImageSets/Main/trainval.txt'
            ],
            img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'],
            pipeline=train_pipeline)),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
        img_prefix=data_root + 'VOC2007/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
        img_prefix=data_root + 'VOC2007/',
        pipeline=test_pipeline))

找到:

samples_per_gpu=2,
workers_per_gpu=2,

修改:将workers_per_gpu从2修改为0,就可以正常debug了。samples_per_gpu指定一张卡里面同时训练几张图片,workers_per_gpu指定进程数,可以改成单进程的来debug。后面使用其他的代码库的时候都可以用类似的思路,修改num_wokers之类的为0即可,亲测基本都能解决问题

你可能感兴趣的:(cv,python,开发语言)