title: How to prevent appending to a list to fill gpu memory
body: <p>I run a model with pytorch with batch inference. I want to save the output from that model to a list, because I need it later for other calculations. The problem is, that if I append the output from my model to my list &quot;output&quot;, it fills the gpu memory.
  The output from the model is a list.
  Is there a way to move the list to RAM?</p>
  <pre><code>if __name__ == &quot;__main__&quot;:
          output = []
          with torch.no_grad():
              for i in input_split:
                  try:
                      preds = model(i)                        
                      output.append(preds)          
                      del preds   
                      gc.collect()
                      torch.cuda.empty_cache()    
  
                  except RuntimeError as e:
                      print(&quot;Failed&quot;)
  </code></pre>