Colab – How to use GPU/TPU on Google Colab?

By | November 7, 2018

Before Colab, I started with Google’s cloud Compute Engine to do deep learning. During free trial, you are not allowed to use GPUs. User is restricted to use 8 vCPUs max. It is fine if you are new and willing to explore cloud platform. You should learn how that works. Before you want to perform heavy deep learning tasks with upgraded paid option, this can be a good start.

However, if you are looking to start off practicing deep learning, Google Colaboratory is perfect choice.Google colaboratory is excellent for deep learning. It lets you use cloud GPU and TPU. It’s free of charge.

It has Jupyter notebooks environment which I find most suitable to do deep learning. You can write code into cells and execute.

Steps to use GPU/TPU on Google Colaboratory:

Step 1 – Open Google Colaboratory, select ‘New Python 3 notebook’

google-colab
google-colab

Step 2 – Rename your notebook

rename-cola-notebook
rename-colab-notebook

Step 3 – Select runtime -> Change runtime type

runtime-colab
runtime-colab

Step 4 – Select GPU/TPU

gpu-tpu
gpu-tpu

That’s all it takes to setup a Jupyter notebook on Colab. Now, you are ready to write your code in cells and execute them. If you are new, I will suggest try creating linear model, then CNN. Train and test your model with dataset like MNIST.