top of page
  • Writer's pictureDRL

Learn to Use Google Colaboratory

Updated: Apr 6

What is Colab?

Google Colaboratory (popularly known as Colab) is a free cloud service by Google that allows users to run Jupyter notebooks with access to GPUs and TPUs. It requires no setups and can be executed instantaneously. One of the features of Colab (other than being free) is having pre-installed libraries like Tensorflow, which take up a lot of data. This is why colab is being used extensively for training and learning.

Why Colab?

There are many more such reasons to use Colab, such as:

  1. Free IDE for Python: Colab is based on Jupyter which is an open source project. It is a specialized version developed by Google which runs on cloud and offers free computing resources.

  2. Easy to share: Colab can be shared easily via link. Sharing authority can be set to view or edit by the author. People with link can edit or view the .ipynb file.

  3. No setups required: Unlike traditional softwares, Colab requires no setup, and no installation. We can straightaway start coding without worrying about peripherals. You directly execute your code on Google servers!!

  4. Import or Save notebooks directly to Google Drive or GitHub: On opening we get options to create a new file or open an existing file. We can open a .ipynb file from Drive or from Github. We can also upload any .ipynb file from our local system.

  5. Pre-installed libraries like Tensorflow, Keras, Scikit and other such libraries: Libraries need to be installed locally to use from Jupyter. But, colab comes pre loaded with frequently used libraries, which saves time.

  6. Can import external data from sheets and runtime instances: Data can be imported to Colab in many ways. We can take data from google sheet, google drive and other popular storage options.

  7. Collection of common code snippets and datasets are also available: Apart from pre-loaded libraries, Colab comes with frequently used datasets and code snippets. These include MNIST dataset, california Housing dataset etc.

Components of Colab

Following figure explains the components of a colab notebook.

How to Use Colab

As per our experience with beginners using colab, the main problem is faced while uploading the data. So we have explained the process of uploading the data in detail in this article. While in-depth explanation on google colaboratory or anaconda is included in our regular Data Science training programs, we are just focusing more on uploading data here.

  • Cells - The building blocks

Cells are used to write python code in the notebook. After writing the code, we can press ctrl+enter to run the cell. Alternatively we can also click on the button on the side of each cell to run the cell.

  • Uploading Data

Since Colab runs on the cloud, we have to upload or import data in our notebooks. Uploading data can be done in the following ways:

From Local Drive - using file.upload()

This is the easiest method to upload files. The downside of file.upload() is that it might take a long time while uploading large files, and on every restart of the notebook, the files have to be uploaded manually each time.

Uploading file in runtime

Clicking on the first icon below the Files heading, allows us to upload files from our systems. This too, like file.upload() is easy but has to be done each time whenever the notebook restarts.

From Google drive

We can mount the google drive using the following code. On running the cell Colab gives us an URL, on clicking the URL we are redirected to the sign in options. After signing in, we will get an unique code, copy the code and paste it in the text field given below the cell.

On successful authorization, a new folder will be added in the Files section named "Content"

Connecting with AWS S3 bucket

connect with sql engine and get data

This approach is amazing for projects which use structured data already available in sql tables. The obvious downside of this approach occurs in projects with unstructured data.

Connecting with SQL Database

connect with sql engine and get data

This approach is amazing for projects which use structured data already available in sql tables. The obvious downside of this approach occurs in projects with unstructured data.


Google Colab is a fantastic tool for all genres of people in the AI field. The functionality it gives for free is beneficial. It is used for learning as well as building complex

models by many. One main characteristic that differentiates Colab from Jupyter is the ease of collaboration available in Colab, not found in Jupyter. We can add comments to cells and share links to others, making it appropriate for "Colab"oration. Along with this, the free GPU access, pre installed libraries, easy user interface and the simplicity of Notebooks, has made this platform a huge hit among students, practitioners, industry people and researchers.

Hope this article will give a steady start to your journey of Colab.

19 views0 comments

Recent Posts

See All
bottom of page