[pytorch] torch.cuda.FloatTensor报错

参考:RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [4, 512, 16, 16]], which is output 0 of ConstantPadNdBackward, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). · Issue #23 · NVlabs/FUNIT · GitHub

pytorch 1.9 报错:

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [4, 512, 16, 16]], which is output 0 of ConstantPadNdBackward, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). #23

开始还以为是输入的  z = torch.randn(batch_size, 128,1,1).to(device) 。

解决办法:

pip install torch == 1.4 torchvision = 0.05

你可能感兴趣的:(pytorch,pytorch,人工智能,python)