马春杰杰 Exit Reader Mode

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 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!