How to empty_cache by passing gpu-tensor as a parameter to a function?
In this case, It works!
x = torch.tensor([1., 2.]).cuda() 
print(torch.cuda.memory_allocated()) # 512
del x 
print(torch.cuda.memory_allocated()) # 0

x = torch.tensor([1., 2.]).cuda() 
print(torch.cuda.memory_allocated()) # 512
cleaner(x)
print(torch.cuda.memory_allocated()) # still 512 ...

def cleaner(x):
   del x