SKNet icon indicating copy to clipboard operation
SKNet copied to clipboard

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [8, 64, 32, 32]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later.

Open Jin-Xi opened this issue 2 years ago • 2 comments

Run sknet.py, got RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [8, 64, 32, 32]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later.

environment: torch1.10 python3.8

Jin-Xi avatar May 12 '22 10:05 Jin-Xi

x.squeeze(),x.unsqueeze_()操作将改变x。x.squeeze(),x.unsqueeze(),下划线去了,但不知道影响大不大

hunyihun123 avatar Oct 24 '22 04:10 hunyihun123

我也遇到了同样的问题,采用了一楼的方法成功解决,感谢一楼!!

better153 avatar Jan 05 '24 02:01 better153