How to clear CUDA memory?

Would somebody suggest how to clear CUDA memory?

Thank you so much.

1 Like

torch.cuda.empty_cache() allows to clear cached memory. However, you should not use it owing to the next fact:

Pytorch does not release the memory back to the OS when you remove Tensors on the GPU, it keeps it in a pool so that next allocations can be done much faster.