马春杰杰博客
致力于深度学习经验分享!

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 256, 25, 36]], which is output 0 of CudnnConvolutionBackward, is at version 1; expected version 0 instead

训练的时候报错:

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 256, 25, 36]], which is output 0 of CudnnConvolutionBackward, is at version 1; expected version 0 instead

主要是梯度求导的问题,可以看下代码里有没有a += xxx这类的代码,把它改成:

a = a + xxx

或者a = a.clone() + xxx

就可以解决问题了。

本文最后更新于2021年8月21日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!

如果你对这篇文章有什么疑问或建议,欢迎下面留言提出,我看到会立刻回复!

打赏
未经允许不得转载:马春杰杰 » RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 256, 25, 36]], which is output 0 of CudnnConvolutionBackward, is at version 1; expected version 0 instead
超级便宜的原生ChatGPT4.0

留个评论吧~ 抢沙发 评论前登陆可免验证码!

私密评论
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址(选填,便于回访^_^)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

登录

忘记密码 ?

切换登录

注册