What is the trick to release GPU memory without having to restart jupyter?

I thought it was learn.destroy() but that isn’t doing it.

learn.purge() ?

i restart the notebook that tied the GPU memory and that releases it

This works for me:

    learn.purge()
    import gc; gc.collect()
    torch.cuda.empty_cache()
    
    !nvidia-smi
5 Likes

Still not working for me.

I wonder if it has something to do with the fact I’m running everything on my personal DL rig using GPU #2 (rather than the default GPU 0).