admin管理员组文章数量:1550528
pytorch利用DDP加速时,出现提示信息为:
[W reducer.cpp:362] Warning: Grad strides do not match bucket view strides. This may indicate grad was not created according to the gradient layout contract, or that the param's strides changed since DDP was constructed. This is not an error, but may impair performance.
原因是因为输入tensor进行过transpose或permute等变形操作后,内部的内存地址变得不连续导致的。
处理方式很简单,在tensor进行transpose或permute等变形操作后,加一句语句.contiguous(),可使内存地址变连续。
例如:
# 原代码为:
input_tensor = ori_tensor.transpose(1, 3)
# 改为:
input_tensor = ori_tensor.transpose(1, 3).contiguous()
版权声明:本文标题:pytorch利用DDP进行加速的报错问题 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1727247460a1104804.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论