Alwin Aind
Alwin Aind

Reputation: 39

Can't use GPU on Google Colab for tensorflow 2.0

I am trying to run my notebook using a GPU on Google Colab, but it doesn't provide me a GPU, however when I run the notebook with tensorflow 1.15.0, the GPU is available.

tf.test.gpu_device_name()

gives the output '/device:GPU:0' for tensorflow 1.15.0

But when I do the same with tensorflow 2.0.0 the function returns ''.

Upvotes: 4

Views: 12480

Answers (4)

MerajS
MerajS

Reputation: 1

According to https://colab.research.google.com/notebooks/gpu.ipynb#scrollTo=oM_8ELnJq_wd

You'll need to enable GPUs for the notebook:

  1. Navigate to Edit→Notebook Settings
  2. select GPU from the Hardware Accelerator drop-dow

Upvotes: 0

Xuanhong Ye
Xuanhong Ye

Reputation: 51

try

%tensorflow_version 2.x

import tensorflow as tf
print(tf.__version__)
print(tf.test.gpu_device_name())
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

Upvotes: 5

Bob Smith
Bob Smith

Reputation: 38674

This is a bug related to 2.0 being incompatible with a recent CUDA 10.1 upgrade on Colab.

The relevant GitHub issue to follow is: https://github.com/googlecolab/colabtools/issues/864

Upvotes: 2

Cristina Bustos
Cristina Bustos

Reputation: 141

I solved installing in google colab

!pip install tensorflow-gpu 

and

!pip install tf-nightly 

So now tf.test.gpu_device_name(), the output is /device:GPU:0 But, TensorFlow automatically upgrade its version to 2.1.0-dev20191120

Upvotes: 7

Related Questions