项目链接:https://github.com/dddzg/up-detr
论文:https://arxiv.org/abs/2011.09094
UP-DETR 遵循两个步骤:预训练和微调。展示了在 ImageNet 上预训练的模型,然后在 COCO 上进行了微调。
环境:在两块2080ti下运行。
预训练
设置‘“--imagenet_path” “--output_dir” 两个地址
单显卡
直接运行是单显卡,多显卡需要额外设置。
在运行之后会报错,RuntimeError: Distributed package doesn’t have NCCL built in。因为NCCL在Linux下,Windows下需要更换。
解决方案:Windows RuntimeError: Distributed package doesn‘t have NCCL built in问题_StarCap的博客-CSDN博客
官方给的是命令行指令运行
python -m torch.distributed.launch --nproc_per_node=8 --use_env main.py --lr_drop 40 --epochs 60 --pre_norm --num_patches 10 --batch_size 32 --feature_recon --fre_cnn --imagenet_path %path/to%/imagenet --output_dir %path/to%/save_model
其中一些参数要注意设置,我是修改参数后直接运行。。
多显卡
这一步指定要用到的显卡是哪块,可以自行选择,如果只有两块,用两块可以不写。
os.environ['CUDA_VISIBLE_DEVICES'] = '3,4'
运行程序
python -m torch.distributed.launch --nproc_per_node=2 --use_env main.py --pre_norm --feature_recon --fre_cnn
注意:不加--pre_norm --feature_recon --fre_cnn,在运行中这些参数的值会有问题。
微调
设置 “--coco_path” “--pretrain”
parser.add_argument('--pre_norm', action='store_true', default=True)
之后多显卡和单显卡运行和预训练一样。