yolov6训练记录和出现的问题

本文详细记录了在使用COCO数据集训练YOLOv6模型过程中遇到的常见问题,如UserWarning、RuntimeError、ImportError等,并提供了相应的解决办法,包括修改配置、更新库版本和模块导入。适合深度学习和目标检测的开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用的coco数据集

  1. 首先修改参数:
    /home/gaoziran/YOLOv6-main/data/coco.yaml/
    在这里插入图片描述
    由于在服务器上跑,直接用绝对路径。

  2. 训练时遇到问题:UserWarning: torch.meshgrid: in an upcoming release
    解决办法:
    修改文件:/home/ubuntu/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/function.py/
    在这里插入图片描述

  3. 训练:
    单卡训练:
    python tools/train.py --batch 32 --conf configs/yolov6n.py --data data/coco.yaml --device 0
    在这里插入图片描述

    双卡训练:
    python -m torch.distributed.launch --nproc_per_node 2 tools/train.py --batch 32 --conf configs/yolov6n.py --data data/coco.yaml --device 0,1

  4. 遇到问题:RuntimeError: Address already in use
    解决办法:加入参数 master_port
    修改如下:
    python -m torch.distributed.launch --master_port 2333 --nproc_per_node 2 tools/train.py --batch 16 --conf configs/yolov6n.py --data data/coco.yaml --device 0,1

  5. 遇到问题:ImportError: cannot import name ‘QuantStub‘ from ‘torch.ao.quantization‘
    解决办法:anoconda3\Lib\site-packages\torch\ao\quantization_init_.py里面粘贴下面内容
    class QuantStub(nn.Module):
    r""“Quantize stub module, before calibration, this is same as an observer,
    it will be swapped as nnq.Quantize in convert.
    Args:
    qconfig: quantization configuration for the tensor,
    if qconfig is not provided, we will get qconfig from parent modules
    “””
    def init(self, qconfig=None):
    super(QuantStub, self).init()
    if qconfig:
    self.qconfig = qconfig

    def forward(self, x):
    return x

  6. 遇到问题:UserWarning: Detected call of lr_scheduler.step() before optimizer.step().
    解决办法:更换torch版本!
    torch-1.10.0+cu113-cp38-cp38
    torchvision-0.11.1+cu113-cp38-cp38

  7. 遇到问题:AttributeError: module ‘distutils‘ has no attribute ‘version‘
    setuptools 版本问题
    解决办法:更换版本
    pip uninstall setuptools
    pip install setuptools==59.5.0

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值