You can simply execute the following piece of code to verify whether it’s working.
>>> import torch
>>> a = torch.cuda.FloatTensor(10000)
>>> print("Allocated:", round(torch.cuda.memory_allocated(0)/10243,1), "GB")
Allocated: 3.9 GB
>>> b = torch.cuda.FloatTensor(20000)
>>> print("Allocated:", round(torch.cuda.memory_allocated(0)/10243,1), "GB")
Allocated: 11.8 GB