How to add report_tensor_allocations_upon_oom to RunOptions in Keras : <p>I'm trying to train a neural net on a GPU using Keras and am getting a "Resource exhausted: OOM when allocating tensor" error.  The specific tensor it's trying to allocate isn't very big, so I assume some previous tensor consumed almost all the VRAM.  The error message comes with a hint that suggests this:</p>

<blockquote>
  <p>Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.</p>
</blockquote>

<p>That sounds good, but how do I do it?  RunOptions appears to be a Tensorflow thing, and what little documentation I can find for it associates it with a "session".  I'm using Keras, so Tensorflow is hidden under a layer of abstraction and its sessions under another layer below that.</p>

<p>How do I dig underneath everything to set this option in such a way that it will take effect?</p>
