Solved by thomasjo in post #4 
              
              
                Are you collecting results, e.g. losses, and storing them in a list or something similar? If you are, make sure you store graph-detached copies of the relevant tensors by calling Tensor.detach. 
losses = []

# Inside training loop or similar
loss = criterion(...)
losses.append(loss.detach())

If you…