title: How to use gpu in .py files Google Colab?
body: <p>I have a notebook in GC with configured gpu computing. When I run in this notebook:</p>
  
  <pre><code>from tensorflow.python.client import device_lib
  print(device_lib.list_local_devices())
  </code></pre>
  
  <p>I can see GPU in devices:</p>
  
  <pre><code>[name: "/device:CPU:0"
  device_type: "CPU"
  memory_limit: 268435456
  locality {
  }
  incarnation: 2881683908768157563
  , name: "/device:XLA_CPU:0"
  device_type: "XLA_CPU"
  memory_limit: 17179869184
  locality {
  }
  incarnation: 14433918882325490908
  physical_device_desc: "device: XLA_CPU device"
  , name: "/device:XLA_GPU:0"
  device_type: "XLA_GPU"
  memory_limit: 17179869184
  locality {
  }
  incarnation: 8857856280193037152
  physical_device_desc: "device: XLA_GPU device"
  , name: "/device:GPU:0"
  device_type: "GPU"
  memory_limit: 15701463552
  locality {
    bus_id: 1
    links {
    }
  }
  incarnation: 13142570581108506915
  physical_device_desc: "device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0"
  ]
  </code></pre>
  
  <p>but when I put this code(nothing else) in .py file (in drive), which I run from shell using</p>
  
  <pre><code>!python3 file.py
  </code></pre>
  
  <p>I can't see GPU in devices:</p>
  
  <pre><code>[name: "/device:CPU:0"
  device_type: "CPU"
  memory_limit: 268435456
  locality {
  }
  incarnation: 5088676628756383267
  , name: "/device:XLA_CPU:0"
  device_type: "XLA_CPU"
  memory_limit: 17179869184
  locality {
  }
  incarnation: 550355900248427842
  physical_device_desc: "device: XLA_CPU device"
  ]
  </code></pre>
  
  <p>How to solve it? I.e. how to use GPU computing in .py files which run from notebook terminal?</p>