Google Colab Introduction

Summary: in this tutorial, you’ll learn about Google Colab and how it fits into the whole data science toolset.

What is Google Colab

Colab is a free Jupyter Notebook environment that runs entirely in the cloud and is a part of Google effort to better embedded in the data science community.

Colab doesn’t require any configuration or installation, which makes it the perfect choice for beginners. A Google account is all you need to start.

Besides being free, the main advantages of Colab over the ordinary Jupyter Notebook document is that the notebooks you create can be edited simultaneously by other users – just like how you would edit documents in Google Docs.

What you can do in Google Colab

  • Write and execute Python code snippets.
  • Write and render mathematical equations.
  • Create / Upload / Share notebooks.
  • Import / Save notebooks from / to Google Drive.
  • Import / Publish notebooks from GitHub.
  • Import external datasets without storing them locally, for example, from Kaggle.
  • PyTorch, TensorFlow, Keras, OpenCV support out of the box.
  • Free cloud virtual machine with GPU-accelerated capabilities (which speeds up machine learning tasks).

Create new Notebook with Google Colab

Note. Since Colab implicitly uses Google Drive to store your notebooks, make sure you are signed in to your Google Drive account before proceeding.

Step 1. Open the following URL in your browser – https://colab.research.google.com. Your browser will display the following screen (assuming that you are logged in to your Google Drive)

Step 2-Click on New Notebook link at the bottom of the pop-up message. The new Notebook will be opened as shown on the screen below.

As you may have noticed, the Colab notebook looks pretty similar to that of Jupyter.

Step 3– Configuring the notebook

Now you need to give your Notebook a name.

By default, the notebook uses the UntitledXX.ipynb naming convention. To rename notebook, click on that name and enter your desired name, as shown here.

Step 4 – Run the first cell

Now that the notebook is properly set up, you can try running a simple Python code cell to see how things work in Colab. The code snippet below prints out the current system time.

import time print(time.ctime())
Code language: Python (python)

You can either run the code by clicking the “arrow” button on the left side of the cell, or press Ctrl + Enter while you’re in the cell.

As soon as you run the cell, the Connect button in the upper right corner will turn into Allocating, indicating that Colab is now creating a new virtual machine and allocating resources to it to run your code.

After a few seconds, your code will be ran and results would show up right below the code cell.

If you hover the cursor in RAM/Disk button, you would see how many RAM and space are allocated to your virtual machine. Google is quite generous as it gives free users about 12GB of RAM and 70 GBs of disk space, as show in the screenshot.

More details about Google Colab features will be covered in our future guides.

Online resources

Summary

  • Colab is a free Jupyter Notebook running entirely online, no installation required.
  • Colab is a Google product.
  • In order to use Colab, you need a Google account
  • Colab resources are allocated after your first code run.

Leave a Comment