Thank you for your follow up, @googlebot

Use “Variable loading policy” = on demand.

As I mentioned I tried many different options, including this one - to no avail.

Python’s history may keep tensors alive (underscore variables like _, _10)

No, this has to do with ipython not releasing GPU ram on OOM - a huge problem for jupyter users. A fix has been proposed almost 2 years ago, but it has never been integrated:

  
      github.com/ipython/ipython
  
  
    
  
    
  

  
    
      fix a memory leak on exception (caused by the stored traceback) 1
    

    
      ipython:master ← stas00:leak-on-exc
    

    
      
        opened 
        
          
        
        Jan 22, 2019
      
      

      
        
          
          stas00
        
      

      
        
          +2
          -0
        
      
    

  


  
  
    
    
  
  


I use 1/0 cell-fix following the oom cell to work around it.

If you don’t pause or use breakpoints, I don’t see how pycharm would allocate cuda memory.

Right, basically you’re saying do not use pycharm debugger.
It’s not allocating cuda memory - it prevents variables from being freed and gc.collect()ed and thus memory from being freed.