Expected to have finished reduction in the prior iteration before starting a new one. This error ind

该错误表明模型的forward输出中有些没有参与到损失函数的计算。解决方案包括确保所有forward输出都参与计算loss,或者删除不必要影响loss的部分。可以设置环境变量TORCH_DISTRIBUTED_DEBUG以获取更多信息帮助定位问题。
摘要由CSDN通过智能技术生成
 RuntimeError: Expected to have finished reduction in the prior iteration before starting
  a new one. This error indicates that your module has parameters that were not used in producing loss. Since `find_unused_parameters=True` is enabled, 
  this likely  means that not all `forward` outputs participate in computing loss. 
  You can fix this by making sure all `forward` function outputs participate in calculating loss. 
If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's `forward` function.
 Please include the loss function and the structure of the return value of `forward` of your module when reporting this issue (e.g. list, dict, iterable).
Parameter indices which did not receive grad for rank 0: 180 181
In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error

报错信息如上,主要是模型forward的输出并没有全部参与计算,按照网上的方法在加载模型时加了一个find_unused_parameters=True参数,还是同样报错,所以解决方法就是看看网络的输出,是不是loss有漏掉的,如果确实有的输出,不需要参与loss的计算,可以在网络中直接删掉即可。

参考博客:
https://blog.csdn.net/weixin_44966641/article/details/120385212

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一位不愿暴露自己的小可爱

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

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

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

打赏作者

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

抵扣说明:

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

余额充值