跑yolov5过程中遇到的一些问题及解决

写在前面:感谢HH师姐的帮助
使用代码:https://github.com/ultralytics/yolov5
问题一

ERROR:Could not find a version that satisfies the requirement torch>=1.4(from -r requirements.txt(line 5))(from versions:0.1.2,0.1.2.post1,0.1.2.post2)
ERROR:No matching distribution found for torch>=1.4(from -r requirements.txt(line5))

解决:
https://www.jb51.net/article/186132.htm

问题二:

torch.cuda.is_available()
false

解决
因为torch 和torchvision的下载需要翻墙,导致下载失败,此时我们需要另外下载
如果需要cpu版本的:
https://www.jb51.net/article/186132.htm
如果需要gpu版本的:
1).打开yolov5-master文件夹下的requirements.txt,注释掉这两行
在这里插入图片描述

2).重新pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
3).翻墙去google下载 torch-1.6.0-cp37-cp37m-win_amd64.whl 以及 torchvision-0.7.0-cp37-cp37m-win_amd64.whl
在这里提供百度网盘链接:
链接:

https://pan.baidu.com/s/1amt6_KLC2xaM6meHtdbo5A
提取码:e5wg
链接:https://pan.baidu.com/s/1R_n_HcSme5C0uXrMrZsL5Q
提取码:9l52
我是不是你们的小可爱 ( •̀ ω •́ )
4)cmd.exe的路径改为.whl所在文件夹,分别输入命令:
pip install torch-1.6.0-cp37-cp37m-win_amd64.whl
pip install torchvision-0.7.0-cp37-cp37m-win_amd64.whl

问题三:

RuntimeError: No such operator torchvision::nms

解决一:
torch 与torchvision版本不对应,查一下版本,重新装一下
查看版本方法:命令板进入python
在这里插入图片描述
解决二:自己编写nms部分的代码
解决三:去其他网站下载gpu版本的torch,也就是说问题二解决了,问题三也跟着解决了

问题四

UnicodeDecode: 'gbk' codec can't decode byte 0X80 in position 242: lllegal multibyte sequence
Process finished with exit code 1

解决:
with open(cfg) as f: 改成 with open(cfg, encoding = ‘UTF-8’) as f:

问题五

RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 15.00 GiB total capacity; 12.06 GiB already allocated; 14.92 MiB free; 12.10 GiB reserved in total by PyTorch)

解决:
参考https://blog.csdn.net/qq_39542170/article/details/109242027
在train的过程中改小 epoch / batch-size / image-size

问题六

using cpu

解决:显卡没有驱动
这种情况才是正确的:
Using CUDA device0 _CudaDeviceProperties(name=‘Quadro P5000’, total_memory=15360MB)

问题七
在这里插入图片描述
问题八 训练的时候出现:

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

解决:
在train.py中加入:

import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"

通道数有问题,之前改的代码我忘记改回来了…找之前能正常运行的网络,把库copy过来

问题九

RuntimeError: Trying to create tensor with negative dimension -1180553024: [-1180553024]

解决:
数太大了导致内存溢出,控制输入的数量 / 并行处理以缓解内存

训练网络的小习惯(本人小白)
1.data和网络code分开放置,所有同类型的网络统一使用一个data就好
2.报错时要准确定位,anaconda部分的代码不要改,改自己网络的代码就好了。
3.文件、图片的处理尽量使用代码
4.结果输出后,重点观察误检和漏检,归纳出具体是哪些图的结果出现了问题,然后寻找原因与解决方法

  • 11
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值