前言:最近在学习yolov5,记录一些报错

1. 张量不对

Sizes of tensors must match except in dimension 1. Expected size 16 but got size 8 for tensor number 1 in the list.

报错信息如下:

Traceback (most recent call last):File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\IPython\core\interactiveshell.py", line 3343, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File "<ipython-input-2-1475e912e0b9>", line 1, in <module>runfile('I:/GraduationProject/yolov5-5.0-sniperitf798/train.py', wdir='I:/GraduationProject/yolov5-5.0-sniperitf798')File "I:\DevSoftware\Python\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfilepydev_imports.execfile(filename, global_vars, local_vars)  # execute the scriptFile "I:\DevSoftware\Python\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfileexec(compile(contents+"\n", file, 'exec'), glob, loc)File "I:/GraduationProject/yolov5-5.0-sniperitf798/train.py", line 543, in <module>train(hyp, opt, device, tb_writer)File "I:/GraduationProject/yolov5-5.0-sniperitf798/train.py", line 88, in trainmodel = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device)  # createFile "I:\GraduationProject\yolov5-5.0-sniperitf798\models\yolo.py", line 93, in __init__m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))])  # forwardFile "I:\GraduationProject\yolov5-5.0-sniperitf798\models\yolo.py", line 123, in forwardreturn self.forward_once(x, profile)  # single-scale inference, trainFile "I:\GraduationProject\yolov5-5.0-sniperitf798\models\yolo.py", line 139, in forward_oncex = m(x)  # runFile "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_implreturn forward_call(*input, **kwargs)File "I:\GraduationProject\yolov5-5.0-sniperitf798\models\common.py", line 210, in forwardreturn torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 16 but got size 8 for tensor number 1 in the list.

初步估计是模型网络结构出了问题。
下面是报错的网络结构:

backbone:# [from, number, module, args]# Shuffle_Block: [out, stride][[ -1, 1, conv_bn_relu_maxpool, [ 32 ] ], # 0-P2/4[ -1, 1, Shuffle_Block, [ 128, 2 ] ],  # 1-P3/8[ -1, 3, Shuffle_Block, [ 128, 1 ] ],  # 2[ -1, 1, Shuffle_Block, [ 256, 2 ] ],  # 3-P4/16[ -1, 7, Shuffle_Block, [ 256, 1 ] ],  # 4[ -1, 1, Shuffle_Block, [ 512, 2 ] ],  # 5-P5/32[ -1, 3, Shuffle_Block, [ 512, 1 ] ],  # 6[ -1, 1, Shuffle_Block, [ 1024, 2 ] ],  # 7-P6/64
#   [ -1, 3, Shuffle_Block, [ 1024, 1 ] ],  # 8]# YOLOv5 v5.0 head
head:[[-1, 1, Conv, [512, 1, 1]], # 7[-1, 1, nn.Upsample, [None, 2, 'nearest']],# 8[[-1, 6], 1, Concat, [1]],  # cat backbone P4 # 9[-1, 3, C3, [512, False]],  # 10[-1, 1, Conv, [256, 1, 1]], # 11[-1, 1, nn.Upsample, [None, 2, 'nearest']], # 12[[-1, 4], 1, Concat, [1]],  # cat backbone P3 # 13[-1, 3, C3, [256, False]],  # 14 (P3/8-small)[-1, 1, Conv, [256, 3, 2]], # 15[[-1, 14], 1, Concat, [1]],  # cat head P4 # 16[-1, 3, C3, [512, False]],  # 17(P4/16-medium)[-1, 1, Conv, [512, 3, 2]],# 18[[-1, 10], 1, Concat, [1]],  # cat head P5[-1, 3, C3, [1024, False]],  # 20 (P5/32-large)[[15, 18, 21], 1, Detect, [nc, anchors]],  # Detect(P3, P4, P5)]

解决方法:在backbone网络末尾加上了Conv,spp,c3网络

# YOLOv5  backbone
backbone:# [from, number, module, args]# Shuffle_Block: [out, stride][[ -1, 1, conv_bn_relu_maxpool, [ 32 ] ], # 0-P2/4[ -1, 1, Shuffle_Block, [ 128, 2 ] ],  # 1-P3/8[ -1, 3, Shuffle_Block, [ 128, 1 ] ],  # 2[ -1, 1, Shuffle_Block, [ 256, 2 ] ],  # 3-P4/16[ -1, 7, Shuffle_Block, [ 256, 1 ] ],  # 4[ -1, 1, Shuffle_Block, [ 512, 2 ] ],  # 5-P5/32[ -1, 3, Shuffle_Block, [ 512, 1 ] ],  # 6[ -1, 1, Conv, [ 1024, 3, 2 ] ],  # 7-P5/32[ -1, 1, SPP, [ 1024, [ 5, 9, 13 ] ] ],# 8[ -1, 3, C3, [ 1024, False ] ],  # 9]

2. [WinError 1455] 页面文件太小

但是开始训练,又报新的错

train: Scanning 'VOC\labels\train' images and labels... 16551 found, 0 missing, 0 empty, 0 corrupted: 100%|██████████| 16551/16551 [00:11<00:00, 1491.29it/s]
train: New cache created: VOC\labels\train.cache
Traceback (most recent call last):File "<string>", line 1, in <module>File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 105, in spawn_mainexitcode = _main(fd)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 114, in _mainprepare(preparation_data)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 225, in prepare_fixup_main_from_path(data['init_main_from_path'])File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_pathrun_name="__mp_main__")File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\runpy.py", line 263, in run_pathpkg_name=pkg_name, script_name=fname)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\runpy.py", line 96, in _run_module_codemod_name, mod_spec, pkg_name, script_name)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\runpy.py", line 85, in _run_codeexec(code, run_globals)File "I:\GraduationProject\yolov5-5.0-sniperitf798\train.py", line 12, in <module>import torch.distributed as distFile "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\__init__.py", line 124, in <module>raise err
OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll" or one of its dependencies.
Traceback (most recent call last):File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\IPython\core\interactiveshell.py", line 3343, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File "<ipython-input-2-1475e912e0b9>", line 1, in <module>runfile('I:/GraduationProject/yolov5-5.0-sniperitf798/train.py', wdir='I:/GraduationProject/yolov5-5.0-sniperitf798')File "I:\DevSoftware\Python\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfilepydev_imports.execfile(filename, global_vars, local_vars)  # execute the scriptFile "I:\DevSoftware\Python\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfileexec(compile(contents+"\n", file, 'exec'), glob, loc)File "I:/GraduationProject/yolov5-5.0-sniperitf798/train.py", line 545, in <module>train(hyp, opt, device, tb_writer)File "I:/GraduationProject/yolov5-5.0-sniperitf798/train.py", line 194, in trainimage_weights=opt.image_weights, quad=opt.quad, prefix=colorstr('train: '))File "I:\GraduationProject\yolov5-5.0-sniperitf798\utils\datasets.py", line 84, in create_dataloadercollate_fn=LoadImagesAndLabels.collate_fn4 if quad else LoadImagesAndLabels.collate_fn)File "I:\GraduationProject\yolov5-5.0-sniperitf798\utils\datasets.py", line 97, in __init__self.iterator = super().__iter__()File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 359, in __iter__return self._get_iterator()File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iteratorreturn _MultiProcessingDataLoaderIter(self)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 918, in __init__w.start()File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\process.py", line 105, in startself._popen = self._Popen(self)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\context.py", line 223, in _Popenreturn _default_context.get_context().Process._Popen(process_obj)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\context.py", line 322, in _Popenreturn Popen(process_obj)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__reduction.dump(process_obj, to_child)File "I:\EnvVariable\ML\Anaconda3\envs\pytorch\lib\multiprocessing\reduction.py", line 60, in dumpForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

出现的原因

电脑在默认情况下没有给I盘分配虚拟内存,所以将Python装在I盘的,在跑程序的时候,没有分配虚拟内存,就会遇到上面的问题。所以,只要给I盘分派虚拟内存即可。如果Python安装在C盘,更改C盘的虚拟内存的值,调大些。

解决方法

  1. 查找:查看高级系统设置
  2. 进行如下图的操作
  3. 重新启动计算机,重新运行程序

3. MP: Hint This means that multiple copies of the OpenMP runtime have been linked into the

解决上面一二问题开始出现新的问题,具体报错如下:

train: Scanning 'VOC\labels\train.cache' images and labels... 16551 found, 0 missing, 0 empty, 0 corrupted: 100%|██████████| 16551/16551 [00:00<?, ?it/s]
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/.
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/.
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/.
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/.
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/.
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/.
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/.
Scanning images:   0%|          | 0/4952 [00:00<?, ?it/s]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/.
val: Scanning 'VOC\labels\val' images and labels... 4952 found, 0 missing, 0 empty, 0 corrupted: 100%|██████████| 4952/4952 [00:05<00:00, 846.03it/s]
val: New cache created: VOC\labels\val.cache
Plotting labels...
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开头添加以下代码:

##OMP报错
import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'

参考:
彻底解决pycharm中: OSError: [WinError 1455] 页面文件太小,无法完成操作的问题–亲测

记录yolov5更改backbone为ShuffleBlock网络迁移训练出错问题以及解决方法相关推荐

  1. 笔记本网络计算机和设备不可见,xp电脑不显示无线网络的七种原因和解决方法...

    xp纯净版系统电脑打开后发现桌面右下角不显示无线网络,如果要设置无线网络都不知道从哪里下手,这到底是怎么回事?造成xp系统不显示无线网络的原因有很多种,下面和大家讲解一下xp电脑不显示无线网络的七种原 ...

  2. 台式计算机突然连接不到网络,电脑突然网络感叹号导致不能上网的解决方法

    相信平时使用电脑的时候都遇到过电脑突然网络感叹号导致不能上网的问题,对于新手的你肯定会不知所措了.那么我们要如何解决该问题呢?下面装机之家分享一下电脑突然网络感叹号导致不能上网的解决方法,如果你遇到相 ...

  3. 计算机到多重网络,windows7多重网络无法连接到internet最佳解决方法

    我们在启动完win7系统之后,都是需要进行本地连接宽带之后才能够正常上网,然而在连接网络偶尔也会出现一些问题,例如有的用户就会出现多重网络无法连接到internet的情况,那么面对这种现象我们应该要怎 ...

  4. 2008服务器看不见无线图标,Win7系统无线网络图标消失不见两种解决方法

    Win7系统无线网络图标消失不见两种解决方法介绍给大家,随着无线网络的普及,家庭.公众场所都开始使用无线网络.使用过程中会遇到一些故障问题,最近有用户发现无线网络消失不见了,无法连接网络上网,遇到这样 ...

  5. Hyper-V虚拟机win7网络红叉,无法上网解决方法

    之前一直都是玩Vmware虚拟机,后来win8之后的系统有Hyper-V虚拟机就开始接触了. Windows 中内置的Hyper-V管理器可以说是给很多人带来了惊喜!至少运行的流畅程度要比Vmware ...

  6. win10网络不出现计算机列表,win10笔记本WiFi网络列表不显示内容的解决方法

    随着WiFi网络的普及,大家生活和办公都离不开了,电脑和手机都需要连接WiFi上网.win10笔记本在连接无线网络wifi的时候,却发现任务栏的网络图标WiFi列表一个无线信号都没有,无法正常连接无线 ...

  7. w7计算机防火墙无法更改,win7系统提示防火墙无法更改某些设置错误代码0x8007437的原因及四种解决方法...

    win7系统提示"防火墙无法更改某些设置,错误代码0x8007437",这该怎么办呢?下面脚本之家的小编就带来win7系统提示防火墙无法更改某些设置错误代码0x8007437的原因 ...

  8. 手游连接无线后提示无网络连接服务器,圣斗士星矢手游网络连接失败进不去解决方法...

    类型:角色扮演大小:0KB语言:中文 评分:10.0 标签: 立即下载 圣斗士星矢手游游戏开测后,玩家下载正确的版本即可体验游戏,服务器新开,玩家进入游戏会碰到各种问题,有玩家碰到网络连接失败进不去的 ...

  9. Win10网络102错误代码该怎么办?360浏览器网络连接错误 错误代码 102的解决方法

    在WIn10系统中使用360安全浏览器的用户反应无法打开网页,提示网络连接错误 错误代码 102 该怎么办?在我们使用360浏览器的时候遇到这样的问题可能是网卡亦有可能是网络需要重置或是spl出错所引 ...

最新文章

  1. 关闭、刷新、跳转、离开当前网页前提示
  2. html省市联动插件,jquery实现的交互体验更友好省市区三级联动插件
  3. 网页调用本地播放器的代码支持ie,chroome, 火狐不支持
  4. 你所忽略的DNS---DNS实战及深度解读
  5. 数据结构与算法笔记(十五)—— 散列(哈希表)
  6. 【word2vec】篇二:基于Hierarchical Softmax的 CBOW 模型和 Skip-gram 模型
  7. 每日干货丨C语言数组知识点总结
  8. 05CRecordset类
  9. 关于INADDR_ANY
  10. VTK(二)vs2010第一个VTK程序。
  11. 如何在 GitHub 上大显身手?
  12. 主日--使徒行传--20150419
  13. 另类的缓存技术(存储数据)
  14. java 药品管理系统_基于Java web的医药药品管理系统
  15. pandas_空值填充|重复数据|异常数据
  16. 深度学习从入门到精通——MTCNN人脸侦测算法
  17. git报错Successfully created project ‘*****’ on Gitee, but initial commit failed解决
  18. 算法实战(二)两数相加
  19. 星起航:抖音小店怎么设置达人佣金
  20. selenium自动化,更新到最新的chrome驱动

热门文章

  1. endnote 进行 convert to plain text操作后word格式大变问题解决办法
  2. 新一代数字化转型信息化总体规划方案
  3. Simulink取最大(小)值方法总结
  4. 中国电子设计自动化(EDA)软件行业未来发展趋势与投资前景分析报告22022-2028年版
  5. hive 查询去除空值_hive 查看数据库表
  6. 已知三点坐标求三角形面积等几何图形学问题算法
  7. miui10读取不了u盘_u盘能识别但无法读取_u盘无法识别如何修复
  8. 使用Synergy控制实现一套键盘鼠标控制多台电脑(windows+linux)
  9. 小学教师计算机培训课程感言,小学教师教学技能培训心得体会
  10. oh-my-posh安装过程问题及注意事项