Torch inplace Wrong ? No Relu and No +=,*=

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

Can you share a minimal reproducible example? An error message by itself means nothing, and having an example code will help identify the problem.

Also, have you tried running your code within the torch.autograd.set_detect_anomaly(True) context manager like the RuntimeError suggests?

1 Like

Thanks,torch.autograd.set_detect_anomaly(True) and with torch.autograd.set_detect_anomaly(True) help me located the error~