目录
报错内容:
CPU下运行GAN代码报错
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2048]] is at version 4; expected version 3 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
报错原因:
torch高于1.4.0以后,梯度更新变了。算G的loss的计算图是包含D的,但是在G的backward之前更新了D的值,这时候再去计算就不是和forward时候对应的梯度了。

在CPU上运行GAN模型时遇到RuntimeError,由于在梯度计算过程中进行了不当的inplace操作。错误源自torch 1.4.0之后的版本更改。解决方法是同时降低torch和torchvision的版本。注意单独修改任何一个库的版本可能无法解决问题。
订阅专栏 解锁全文

3147

被折叠的 条评论
为什么被折叠?



