Did you solve the new error?
It usually means that you’ve detached the computation graph at some point.
Note that .item() would be such an operation, but if loss doesn’t contain a grad_fn then it was already detached before.
Let me know, if you get stuck.