Freeing GPU memory

Hi all,
How can I delete the input tensor from gpu when it is not needed. ‘del’ is not working for me. I am in pytorch 0.4.

Thanks in advance

By ‘del’ not working, I assume you do not observe any change in memory consumption through nvidia-smi.

Pytorch will cache GPU memory, so even though it looks as though the memory hasn’t been freed, but it actually has. If you really want to see the effect on nvidia-smi, you can call torch.cuda.empty_cache(). Doing this you can observe the effect of deleting tensors in nvidia-smi

1 Like