I have a train_cell: where I call my training function (there I have a function and I call it right after definition).
But this cell requires all prev cells (prep_cells) to be executed (imports, data preparation, etc.)
I also have an exception_cell where I do 1/0 (ZeroDivision exception).
And mem_clear_cell where I call torch_clear_gpu_mem()

I run prep_cells, train_cell

Interrupt training, GPU memory usage: 9GB
Run mem_clear_cell, GPU memory usage: 4GB (no matter how many times I run clear, gpu memory usage doesn’t go down)
Run exception_cell, then mem_clear_cell, GPU memory usage: 935MB
Then I can just call  train_cell without calling prep_cells


So with exception approach to clearing GPU memory I don’t need to restart kernel and run prep_cells before running train_cell