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

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

就可以解决问题了。

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

打赏
未经允许不得转载:马春杰杰 » 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
蝴蝶PT招人啦

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

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

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

支付宝扫一扫打赏

微信扫一扫打赏

切换注册

登录

忘记密码 ?

切换登录

注册