one of the variables needed for gradient computation has been modified by an inplace operation

错误:

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3, 32, 1, 1]] is at version 3; expected version 2 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. Good luck!

解决:

更新pytorch版本。

我这里是1.5.1+cu101出现上述报错,换到1.1.0没有上述错误了。

完整粘贴:

 

posted @ 2021-03-05 09:55  皮卡皮卡妞  阅读(405)  评论(0编辑  收藏  举报