YOLOv7 开启 --image-weights DDP 训练时候遇到的错误:RuntimeError: Tensors must be CUDA and dense

在使用DDP模式训练YOLOv7模型时,如果启用了--image-weights参数,会出现'RuntimeError: Tensors must be CUDA and dense'的错误。原因是该参数与DDP不兼容。解决方法包括不使用--image-weights或者在单GPU上训练带有--image-weights的模型。YOLOv5的作者确认了这一不兼容问题,并在新代码中给出了相应提示。
摘要由CSDN通过智能技术生成

YOLOv7 开启 --image-weights DDP 训练时候遇到的错误:RuntimeError: Tensors must be CUDA and dense

前提:

使用 DDP 模式来训练模型,我开启了 --image-weights 参数,结果报如下错误:

Traceback (most recent call last):
  File "train.py", line 614, in <module>
	train(hyp, opt, device, tb_writer)
  File "train.py", line 320, in train
	dist.broadcast(indices, 0)
  File "/home/xxx/conda/envs/landmark/lib/python3.8/site-packages/torch/distributed/distributed_c10d.py", line 1193, in broadcast
	work = default_pg.broadcast([tensor], opts)
RuntimeError: Tensors must be CUDA and dense
原因:
--image-weights 参数 与 DDP 不兼容。
解决:

方法1: 不开启 --image-weights 参数。

方法2: so the natural solution is to train --image-weights on single GPU.

参考:

YOLOv5 作者说两者不兼容,他在新的代码中添加了一个提示。

https://github.com/ultralytics/yolov5/issues?q=tensors+must+be+cuda+and+dense+

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

理心炼丹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值