title: I forgot to close a tf.InteractiveSession, how do I kill any left over processes?
body: <p>I am using the new <a href="https://colab.research.google.com" rel="nofollow noreferrer">Google Colaboratory</a>, and I ran a block of code repeatedly that utilized a <code>tf.InteractiveSession</code> before I realized that <code>tf.InteractiveSession.close()</code> was never called. I modified the code and added a <code>sess.close()</code>. Now whenever I run the same code block, I get the following warning:</p>
  
  <blockquote>
    <p>/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py:1645: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call <code>InteractiveSession.close()</code> to release resources held by the other session(s).
      warnings.warn('An interactive session is already active. This can '</p>
  </blockquote>
  
  <p>Whoops. How can I release resources held by the previous sessions I spawned? Even after adding the <code>sess.close()</code> command, this warning persists. I assume I am only closing the active session at this point. I tried refreshing the page, but no luck. </p>
  
  <ul>
  <li>Yeah, in case you can't tell I'm not very familiar with the inner workings (including memory management and state persistence) of Jupyter notebooks.</li>
  </ul>
  
  <p>This question is very similar to: <a href="https://stackoverflow.com/questions/50229091/is-it-necessary-to-close-session-after-tensorflow-interactivesession">Is it necessary to close session after tensorflow InteractiveSession()?</a> but I need to know how to actually close the zombie processes, which isn't covered in this answer.</p>