What Is Google Colab?

Nir Thakali
The Startup
Published in
5 min readJul 29, 2020

Introduction

As a beginner to the Python development, you must have faced the daunting task of installing and configuring Python before your run your first “Hello World” code.

The configuration increases if you want to perform specialized tasks such as machine learning, computation analysis, data exploration. Again, the question arises of whether your system has a supported GPU to train machine learning models. Your model training might be too slow, if your training device doesnot have a GPU.

The steps for writing your Python code includes:

  1. Meet a proper hardware requirements.
  2. Download Python executable file.
  3. You might want to create the virtual environment to run different version of the python. (Optional)
  4. Choosing the IDE to run your program. From Visual Studio, Pycharm, Atom, Esclipse and many more
  5. Download conda if you want to develop for Data science.
  6. Then, install the libraries and framework required for your project. For instance, NumPy, Panda, Matplotlib, etc.
  7. Furthermore, you might also want to install the jupyter notebook.

This can be complex for the beginner. To be fair, once it is installed, you donot need to configure again.

However, to simplify this task you can run a Docker container. But again, you are including additional technology to your stack, when you just want to run a damn Hello world program.

Wouldn’t it be better if you could skip all the above steps and start writing a program? Moreover, what about if you get free GPU and TPU for your computation heavy task. Does it sound too good to be true? That’s what a Google Colab is.

Google Colab is a Jupyter notebook environment that runs completely on a cloud. It handles all the setup and configuration required for your program. So that you can start writing your first program.

From the google colab faq page.

Colaboratory, or “Colab” for short, is a product from Google Research. Colaballows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education.

How to run a code in Google Colab?

Running code in Google Colab is as easy as opening any website. It requires just 2 steps. Yes, you heard me correct.

  1. Sign into Google colab.
  2. Create a new notebook.

That’s it. Now you can start writing your code.

  1. Sign in to google colab.

To Sign in to google colab, you need to go to Google Colab url:

https://colab.research.google.com

The home page of the Google Colab looks like below:

1) Google Colab Home page

After you login to the Google Colab. It will give you the option of creating a new notebook in different ways. The background colour might looks different in your system. It’s because, I have changed my background to dark mode.

You can create/open a notebook from:

  1. A recent notebook you have created.
  2. A notebook you have saved in Google drive.
  3. Cloning of notebook from the git repositories .
  4. Upload from the local storage.
  5. Or simply create a new one from the Colab itself.

For this blog, Let us create a new notebook from the Goggle Colab. It is easiest and the fastest way for the begineer to start coding in the Colab notebook.

Creating a new notebook in the Colab:

  1. Select a new notebook option from pop up window shown in the above picture. However, you can create a new notebook by going to the file menu and select “New notebook”.

2. You can change the name of the notebook by double clicking on the file name at the top left near google drive logo. However, donot change the extension of the file. The notebook always should have the “ipynb” extension.

3. You are ready to write your python code. There are two option in the main page to write your code or text.

a) Text is for the information or the description of the code. It is just for display.

b) Code is where you write your code.

You can hover in the center of the screen to get the option to write code or text as show in figure below.

4. Now you can start writing your code in Google Colab.

Click on the play button at the left side of the code editor to run your program. You can create multiple code editors as shown below.

Saving your notebook.

By default, the notebooks have a maximum lifespan of upto 12 hours. Thus, it is recommended to save your work before you exit Colab. There are many options to save your notebook. Like opening a new notebook, the notebooks can be saved to your google drive, local storage, or can be pushed to your git repositories.

Using a GPU or TPU in Colab:

By default, the GPU and TPU are disabled for the notebooks. Nevertheless, They can easily be turned on. The steps to turn on the gpu are:

  1. Click Runtime located in menu bar.

2. Select the Change Runtime type.

3. Select GPU/TPU from the hardware accelerator.

That’s it. You now have the powerful GPU to run your computational model for free.

Conclusion:

Thus, google colab is the power tool for data scientist, machine learning enthusiast or beginner python programmer to run the python code without the hassle of python configuration. It is free, easy to use and has a great sharing feature that lets you share your work with other people easily.

--

--