[Solved][Pytorch1.5] RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

Try moving all the optimizer steps to the very end after all the backwards have completed

See these two similar issues:

2 Likes