windows 配置Co-DETR踩坑笔记

         我用的是windows系统单卡训练,所以没有用官方的bash脚本,而是直接使用train.py进行训练。主要问题集中在mmcv的安装上。

1、报错:subprocess-exited-with-error

完整报错:fatal: unable to access 'https://github.com/open-mmlab/mmtracking/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.
  error: subprocess-exited-with-error
  
  × git reset --hard -q e79491ec8f0b8c86fda947fbaaa did not run successfully.
  │ exit code: 128
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git reset --hard -q e79491ec8f0b8c86fda947fbaaa did not run successfully.
│ exit code: 128
╰─> See above for output.

        使用pip install -r requirements.txt配置环境时,无法访问https://github.com/open-mmlab/mmtracking。

解决方法:去https://github.com/open-mmlab/mmtracking#egg=mmtrack下载源码,把下载源码解压到python安装包的目录或不会被删除的目录,进入到解压的目录,输入

pip install -e .

通过源码安装mmtracking。 

2、from mmcv.ops import RoIPool报错

        一般是直接pip install mmcv-full或者pip install mmcv时会出现这个错误。

解决方法:

pip install mmcv-full==1.5.0 -f https://download.openmmlab.com/mmcv/dist/cu115/torch1.11.0/index.html

(上面的cu115/torch1.11.0改成你自己的版本)

3、报错:from typing import Literal, ImportError: cannot import name ‘Literal’

        主要是因为只有Python 3.8 及更高版本才支持typing.Literal我按照官方推荐的环境,用的是python 3.7,所以不支持typing.Literal。

解决办法:

在最后一行报错的vison_transformer.py中,去除from typing import 中的Literal并加入如下代码:
try:
    from typing import Literal
except ImportError:
    try:
        from typing_extensions import Literal
    except ImportError:
        raise ImportError("Cannot import 'Literal' from 'typing'")

4、报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte

解决方法:

尝试不同的编码方式,或者在最后一行报错的env.py中,

env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()改为

env_info['MSVC'] = cc.decode(encoding,'ignore').partition('\n')[0].strip()

5、报错:RuntimeError: CUDA error: no kernel image is available for execution on the device

完整报错:RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

        这个问题卡了我最久,先是重装了pytorch、torchvision和cuda,没有用。后面又卸载并改装不同cuda版本的pytorch也没用,最后卸载了mmcv,装了更高版本的mmcv,成功解决了问题。(之前报错用的是官方的mmcv==1.5.0,换成了1.6.0版本解决问题)

6、训练自己的数据集

        先将自己的数据集转换成coco数据集,再去对应的_base_配置中修改data_root变量为自己的coco数据集路径。(我这里是coco_detection.py)

        然后在该文件下分别修改train,test,val下ann_file和img_prefix的值(训练的batch_size在这里设置会被后面继承的config文件覆盖掉)。

        在配置文件中将所有的num_classes修改为自己的类别数。

        在mmdet/core/evaluation/class_names.py修改coco_classes函数:return['自己数据集的类']:

在mmdet\datasets\coco.py修改CocoDataset类中的CLASSES=('自己数据集的类')。

7、报错:RuntimeError: CUDA out of memory.

完整报错:RuntimeError: CUDA out of memory.Tried to allocate 490.00 MiB (GPU 0; 6.00 GiB total capacity; 5.82 GiB already allocated; 0 bytes free; 5.86 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

         batchsize过大,显卡显存不足。

解决方法:

需要在配置文件中将samples_per_gpu调小。(不知道为什么,我6g的显存,batchsize最大只能设为1,有知道的可以在评论区说一下)

data = dict(  ##这里samples_per_gpu/workers_per_gpu是batch_num
    samples_per_gpu=2,
    workers_per_gpu=1,
    train=dict(filter_empty_gt=False, pipeline=train_pipeline),
    val=dict(pipeline=test_pipeline),
    test=dict(pipeline=test_pipeline))

成功训练

  • 11
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
配置RT-DETR环境,你需要进行以下步骤: 1. 首先,你需要解压数据集压缩包。可以使用以下命令进行解压: ```shell python ppdet/modeling/tests/test_architectures.py 2.8 ``` 2. 确保你的系统满足以下要求:4个V100的CUDA版本大于等于11.7.1,NCCL版本大于等于2.7,以及PaddlePaddle-GPU版本大于等于2.4.1。 3. 创建一个名为ppdet的conda环境,并使用Python 3.10版本。可以使用以下命令创建环境: ```shell conda create --name ppdet python=3.10 ``` 4. 确认你的NCCL版本号。可以使用以下命令查看NCCL版本号: ```shell cat /usr/include/nccl.h | grep NCCL_MAJOR -A 2 ``` 5. 安装RT-DETR推荐的Paddle版本。 6. 如果你还没有安装cuDNN,可以参考《CUDA & cuDNN Installbook by Eric》进行安装。另外,你需要配置环境变量`LD_LIBRARY_PATH`,将其指向cuDNN的安装路径。可以使用以下命令进行配置: ```shell export LD_LIBRARY_PATH=/home/songyuc/anaconda3/envs/paddle/lib ``` 完成以上配置步骤后,你就可以开始使用RT-DETR了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [RT-DETR的学习笔记](https://blog.csdn.net/songyuc/article/details/130242093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值