Hi,
I still see the memory capacity insistently remains unchanged upon the following two different codes;

x.detach(),
del x,
torch.cuda.empty_cache()
I checked the attribute of x right after x.detach().cpu() and x still has
is_cuda True,
grad_fun SelectBackward,
requires_grad True

So the second code is with replacing x.detach().cpu() with x=  x.detach().cpu() and see the x attributes right after x=  x.detach().cpu() as follows;
is_cuda False,
grad_fun None,
requires_grad False
Even requires_grad and backward related attributes go away successfully, x still remains on gpu memory. Is there any insight to delet x out of gpu memory ?
I am hesitated to use with torch.no_grad(): because I need a few variables in a loop to have requires_grad True for backward operartion.
Thank you in advance.