Connecting to local runtime google colab with GPU needs tensorflow-gpu?

Viewed 369

My PC has no GPU installed and to speed up execution I want to use GPU suggested by google colab by connecting to a local runtime (because the dataset I'm using is too large to be uploaded on google drive). I have normal tensorflow installed on my pc and when I try to run my code on google colab with GPU there's no change in speed. To be able to use google colab GPU do I need to install tensorflow-gpu on my pc? The version of tensorflow-gpu must be the same as tensorflow?

1 Answers

You'll need to enable GPUs for the notebook in Google Colab:

Navigate to Edit and select Notebook Settings

Select GPU from the Hardware Accelerator drop-down

After that You can confirm that we connected to the GPU with tensorflow by running below code:

%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))

Output:

TensorFlow 2.x selected.
Found GPU at: /device:GPU:0

Please refer this link suggested by Google Colab to connect with local runtime,

Related