报错解决:RuntimeError: Expected to h

2024-03-07  本文已影响0人  JIAWEIJIAWEI

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

解决方法
一、

找出参数

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博客

上一篇 下一篇

猜你喜欢

热点阅读