Could you remove the .data usage, as it’s not recommended and might yield unwanted side effects.
This shouldn’t create the increased memory usage, but is nevertheless recommended.
Also, the loss.detach() operation won’t have any effect, as it’s not an inplace operation (also shouldn’t create the memory issue).
To debug the increased memory usage, could you add print statements into your code and check, where the memory is increasing?
You could use:
print(torch.cuda.memory_allocated() / 1024**2)

Usually users forget to detach() tensors before storing them in lists, so that the complete computation graph will be stored as well.
However, the epoch_acc should already be detached. You could check if by printing the tensor’s .grad_fn.