TensorFlow | TF with Google Colab

In the previous post we installed TensorFlow locally, in this post we will learn about Google Colaboratory that allows anybody to write and execute arbitrary python code through the browser.

Overview

In the previous section we installed TensorFlow locally, in this section we will learn about Google Colaboratory that allows anybody to write and execute arbitrary python code through the browser and Colab is free of charge to use.

What is Google Colaboratory

Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs.


Difference between Jupyter and Colab

Jupyter is the open source project on which Colab is based. Colab allows you to use and share Jupyter notebooks with others without having to download, install, or run anything.


How to use Google Colaboratory

Follow below steps to get started with Google Colab.

1. Navigate to Google Colab and Sign in using google account.

google-colab

2. In the File Menu click on New notebook. It should open an Untitled notebook in other tab.

google-colab

3. In the File Menu click on Rename and provide name for your notebook i.e. tf_with_gcptutorials.

google-colab

google-colab

4. Write below code snippet in the code cell to import TensorFlow and to check it's version and click on Run cell.

   
  import tensorflow as tf
  print(tf.version.VERSION)
   

google-colab


Using Free GPU on Google Colaboratory

Colab offers optional accelerated compute environments, including GPU and TPU. Follow below steps to use GPU to run the above code snippet.

5. Navigate to Runtime Menu and click on Change runtime type.

google-colab

6. In the Hardware accelerator select GPU and click on Save.

google-colab

7. Navigate to Runtime Menu and click on Restart and run all to run the code on GPU.

google-colab