问题1:
TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
解决问题:
根据错误提示找到
/home/xx/anaconda3/envs/deepshare/lib/python3.7/site-packages/torch/tensor.py文件的第621行
或者直接单击错误提示栏进入

 def __array__(self, dtype=None):if dtype is None:return self.numpy()else:return self.numpy().astype(dtype, copy=False)

中的

return self.numpy()

改为:

return self.cpu().detach().numpy()

再次运行训练指令即可正常运行,问题解决

参考:https://blog.csdn.net/qq_44703886/article/details/117231542
同理:

Traceback (most recent call last):File "train.py", line 456, in <module>train(hyp, opt, device, tb_writer)File "train.py", line 314, in trainresults, maps, times = test.test(opt.data,File "/media/xx/新加卷/yolov5-master-ubuntu/test.py", line 193, in testplot_images(img, output_to_target(output, width, height), paths, str(f), names)  # predictionsFile "/media/xx/新加卷/yolov5-master-ubuntu/utils/general.py", line 942, in output_to_targetreturn np.array(targets)File "/home/xx/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/_tensor.py", line 643, in __array__return self.numpy()
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

问题2:
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
解决问题:
145行加上 with torch.no_grad():
具体更改为:

def _initialize_biases(self, cf=None):  # initialize biases into Detect(), cf is class frequency# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.m = self.model[-1]  # Detect() modulefor mi, s in zip(m.m, m.stride):  # fromb = mi.bias.view(m.na, -1)  # conv.bias(255) to (3,85)with torch.no_grad():b[:, 4] += math.log(8 / (640 / s) ** 2)  # obj (8 objects per 640 image)b[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum())  # clsmi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

参考:https://blog.51cto.com/u_15194128/2795983

问题 3:如果报显卡和pytorch不兼容
例如:显卡A6000算力高,而你的torch版本支持的算力达不到。
解决方法:可以升级torch版本

问题4:RuntimeError: Unable to find a valid cuDNN algorithm to run

Traceback (most recent call last):File "train.py", line 586, in <module>main(opt)File "train.py", line 485, in maintrain(opt.hyp, opt, device)File "train.py", line 315, in trainscaler.scale(loss).backward()File "/home/image522/anaconda3/envs/yolov5_v5.0/lib/python3.8/site-packages/torch/tensor.py", line 245, in backwardtorch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)File "/home/image522/anaconda3/envs/yolov5_v5.0/lib/python3.8/site-packages/torch/autograd/__init__.py", line 145, in backwardVariable._execution_engine.run_backward(
RuntimeError: Unable to find a valid cuDNN algorithm to run convolution

解决方法: 修改batch-size大小

Ubuntu系统yolov5训练报错集合相关推荐

  1. 更新 Ubuntu 系统,避免报错「校验和不符」

    为什么80%的码农都做不了架构师?>>>    1. 问题 使用 Ubuntu 操作系统,执行 sudo apt-get update 更新系统时,经常会见到类似如下所示的报错信息: ...

  2. Ubuntu系统 软件安装报错:Could not get lock /var/lib/dpkg/lock-frontend - open解决方法

    ​ 问题 在Ubuntu系统上安装使用apt-get install命令安装软件报以下错误: E: Could not get lock /var/lib/dpkg/lock-frontend - o ...

  3. Ubuntu系统rosdep update报错的解决办法(2022.10.3亲测有效)

    目录 一. 问题: Ubuntu22.04系统下面,rosdep update总是报错 二. 方法一一道来: 1. 直接访问raw.githubusercontent.com是不行的. 按照网上的解决 ...

  4. YOLOv5训练报错:result type Float can‘t be cast to the desired output type __int64

    记录一个报错: 因为把Pytorch版本从1.8.0更新到1.13.1,YOLOv5-6.1版本的训练代码报错: RuntimeError: result type Float can't be ca ...

  5. yolov5 v3.0训练报错: torch.nn.modules.module.ModuleAttributeError: ‘BatchNorm2d‘ object has no attribute

    欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 yolov5 v3.0版本训练报错:torch.nn.modules.module.ModuleAttributeErr ...

  6. PyCharm使用期间出现报错集合 持续更新ing

    PyCharm使用期间出现报错集合 持续更新ing 啥时候用PyCharm发现了奇奇怪怪的错误就整理上来 这几天帮同学安装torch的时候出现了一些奇奇怪怪的问题 1.torch始终安装失败 描述一下 ...

  7. Temporary failure resolving——Ubuntu DNS未配置报错与解决

    Temporary failure resolving--Ubuntu DNS未配置报错与解决记录 环境信息: WSL Ubuntu 18.04 LTS 安装unzip命令所需的工具包 sudo ap ...

  8. Ubuntu用apt-get安装报错:E: Could not get lock /var/lib/dpkg/lock-frontend - open (11:资源暂时不可用)

    Ubuntu用apt-get安装报错:E: Could not get lock /var/lib/dpkg/lock-frontend - open (11:资源暂时不可用) 文章目录: 一.错误原 ...

  9. 服务器 独立显卡 显示不出来,dell服务器R720+独立显卡GTX1650,进不去系统,UEIF报错...

    戴尔服务器dell R720的显卡问题.操作系统是win2008R2. 现在是安装的华硕750ti,运行ok,多个屏幕. 买了技嘉gtx1650,刚出的显卡安装了.在集成显卡情况下打了驱动,设备管理显 ...

最新文章

  1. redis mysql查询数据类型_linux 常见的标识与Redis数据库详解
  2. 国拨经费约31.48亿!科技部发布科技创新2030 —“脑科学与类脑研究”重大项目2021年度项目申报指南
  3. EOS净流入超3亿,比特币继续震荡盘整
  4. 教你用U盘安装Ubuntu
  5. 【LeetCode】169. Majority Element
  6. 不知道被谁删了微信好友?用 Python 来帮忙呀
  7. Java 23 种设计模式
  8. Transformer详细解读与预测实例记录
  9. 【无码专区1】简单路径的第二大边权(启发式合并+最小生成树)
  10. linux系统读取excel文件是否存在,小弟我用poi读excel,在window下没有有关问题,但把程序放到linux上时,读取客户端的excel文件报错,不...
  11. springboot redis 断线重连_Redis高可用方案实现
  12. 中国女性补体面膜市场趋势报告、技术动态创新及市场预测
  13. iTerm2 如何设置以单词为单位快速移动光标?
  14. Spring IOC源码笔记(一)
  15. 信息学奥赛一本通(C++版) 第三部分 数据结构 第四章 图论算法
  16. Android编程入门-第1天
  17. 物联网工程专业该怎么学?老学长吐血整理!!
  18. 【华人学者风采】Ting Xu 加州大学伯克利分校
  19. 关于SQL语句的分类及DQL语句执行顺序
  20. UVALive 5075 Intersection of Two Prisms(柱体体积交)

热门文章

  1. 用旧平板打造家庭云数码相框
  2. 速记计算机键盘,中文速记电脑编码方法及输入键盘技术
  3. MySQLSyntaxErrorException
  4. 分布式架构的几种实现方式
  5. VUE中$refs和$el的使用
  6. hadoop安装步骤
  7. 自媒体必看:这3个领域别做,起步慢、收益低
  8. XManager5 ssh远程登录服务器工具xshell ,服务器资源上传下载工具xftp
  9. 多级CIC滤波器的matlab仿真
  10. 怎么禁用笔记本触摸板