Remember that each node you save in a list stores the whole computation graph assigned to it.
This is quite a common issue regarding memory leaks.
E.g. if you save the loss for debugging/printing purposes with losses += loss instead of losses += loss.item(), the whole computation graph will be stored and cannot be freed.
Could you check for these issues?