RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation; code worked in PyTorch 1.2, but not in 1.5 after updating

Hi,

You can check the update doc for 1.5 and in particular the section about optimizers and inplace.
We fixed the inplace detection for optimizer and the inplace operation that is problematic here is the optimizer.step() that changes the weights inplace.
You will need to either move the .step() after both backward. Or re-do the forward with the new weights values after the .step() has been done.

2 Likes