美文网首页
报错解决:RuntimeError: Expected to h

报错解决:RuntimeError: Expected to h

作者: JIAWEIJIAWEI | 来源:发表于2024-03-07 10:53 被阅读0次

有部分参数初始化了,但是并没有在模型的foward过程中使用,因此没有梯度无法反传参数更新。也可能是使用了if else结构的导致某分支没有使用到。

解决方法
一、

  • 如果确实某些网络结构是不需要使用的,那我们就直接去除即可,但首先我们需要debug出哪些参数和结构是没有被用到了,然后针对性去除即可:

找出参数

  • 只需要在你正常的分布式命令前加入TORCH_DISTRIBUTED_DEBUG=DETAIL即可:
TORCH_DISTRIBUTED_DEBUG=DETAIL bash tools/dist_train.sh config/xxx.py 1
image.png

二、
也可以直接在命令后加入--cfg-options find_unused_parameters=True

bash tools/dist_train.sh config/xxx.py 1 --cfg-options find_unused_parameters=True

可能会影响效果,建议直接找到未使用参数。

参考:MMDet——报错解决:RuntimeError: Expected to have finished reduction in the prior iteration before_torch_distributed_debug-CSDN博客

相关文章

网友评论

      本文标题:报错解决:RuntimeError: Expected to h

      本文链接:https://www.haomeiwen.com/subject/zjvszdtx.html