title: Tensorflow allocating GPU memory when using tf.device('/cpu:0')
body: <p><strong>System Info</strong>: 1.1.0, GPU, Windows, Python 3.5, code runs in ipython consoles.</p>
  <p>I am trying to run two different Tensorflow sessions, one on the GPU (that does some batch work) and one on the CPU that I use for quick tests while the other works.</p>
  <p>The problem is that when I spawn the second session specifying <code>with tf.device('/cpu:0')</code> the session tries to allocate GPU memory and crashes my other session.</p>
  <p>My code:</p>
  <pre><code>import os
  os.environ[&quot;CUDA_VISIBLE_DEVICES&quot;] = &quot;&quot;
  import time
  
  import tensorflow as tf
  
  with tf.device('/cpu:0'):
    with tf.Session() as sess:
      # Here 6 GBs of GPU RAM are allocated.
      time.sleep(5)
  </code></pre>
  <p>How do I force Tensorflow to ignore the GPU?</p>
  <h1>UPDATE:</h1>
  <p>As suggested in a comment by @Nicolas, I took a look <a href="https://stackoverflow.com/questions/37893755/tensorflow-set-cuda-visible-devices-within-jupyter/37901914#37901914">at this answer</a> and ran</p>
  <pre><code>import os
  os.environ[&quot;CUDA_VISIBLE_DEVICES&quot;] = &quot;&quot;
  import tensorflow as tf
  
  from tensorflow.python.client import device_lib
  print(device_lib.list_local_devices())
  </code></pre>
  <p>which prints:</p>
  <pre><code>[name: &quot;/cpu:0&quot;
  device_type: &quot;CPU&quot;
  memory_limit: 268435456
  locality {
  }
  incarnation: 2215045474989189346
  , name: &quot;/gpu:0&quot;
  device_type: &quot;GPU&quot;
  memory_limit: 6787871540
  locality {
    bus_id: 1
  }
  incarnation: 13663872143510826785
  physical_device_desc: &quot;device: 0, name: GeForce GTX 1080, pci bus id: 0000:02:00.0&quot;
  ]
  </code></pre>
  <p>It seems to me that even if I explicitly tell the script to ignore any CUDA devices, it still finds and uses them. Could this be a bug of TF 1.1?</p>