tensorflow: GPU device not found in Colab

My code worked well with GPU in Colab yesterday. But this morning it became very slow. So I suspect that CPU is used despite hardware accelerator is set to GPU in “change runtime type” explicitly. So I check the availability of GPU following the tutorial: https://colab.research.google.com/notebooks/gpu.ipynb

code chunk:

%tensorflow_version 2.x
import tensorflow as tf
device_name = tf.test.gpu_device_name()
if device_name != '/device:GPU:0':
  raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))

Indeed, I got SystemError: GPU device not found. I tried this with different sessions or google user accounts, the same results. You should be able to replicate this in a new Colab session. Maybe some tensorflow updates are involved? It could be that Colab session provide GPU, but tensorflow can’t see it, e.g. tf.test.gpu_device_name() or tf.test.is_gpu_available(). Please help, thank you!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Open google Colab -> Right top corner find RAM/Disk -> Dropdown ->View resources - >change runtime -> hardware accelerator -> select GPU -> save .This solves the issue

UPDATE: GPU is working with TF 2.0 now in Colab. Thanks for all your comments/suggestions.

I still got the same error; why is that?

The best available hardware is prioritized for users who use Colaboratory interactively rather than for long-running computations. Users who use Colaboratory for long-running computations may be temporarily restricted in the type of hardware made available to them, and/or the duration that the hardware can be used for. See Why are hardware resources such as T4 GPUs not available to me? You may try shut down current notebook and start a new one.