MITB Banner

5 Google Colab Hacks One Should Be Aware Of

Share

COLAB

Google Colab has been a boon to the data science community since it allows users to work with large datasets of machine learning or deep learning algorithms on their own machines, without relying on an upgrade, which can be a costly affair. With several pre-installed libraries and the availability of GPU and TPU options, it is already popular among many.

Users who are just getting started with Google Colab can go through this article and learn how to navigate the platform. Since we are through with the step-by-step guide, what follows are some hacks and tricks that can further enhance and streamline a user’s experience with Google Colab. These hacks will help save their time, and also broaden their overall knowledge of the platform.

RAM Expansion

Google Colab comes with a RAM capability of 13GB. While this can be termed good, it may be insufficient at times since several deep learning models require a lot more space. When a situation like this arises, there is a way to expand the RAM. 

The trick is simple and almost doubles the existing RAM of 13GB. This can be done by inputting a certain code in the Google Colab cell and waiting for the Colab to crash.

i = []

while(True):

    i.append(‘a’)

As soon as the platform crashes due to lack of RAM, the platform automatically shows an option which readers – Your Session Crashed After Using All Available RAM.

One needs to click on the option- Get More RAM

Once the option is clicked, the platform creates a dialogue box which comes with a message ‘Switch to a high-Ram runtime?

Clicking on ‘Yes’ will do the magic and a user will have 25 GB of RAM in hand.

Stay Connected

Google Colab often disconnects the notebook if a system is kept idle for more than 30 minutes. This can be a huge disappointment for someone who has kept a model on training and left to do some other work. But there is an easy solution, which is nothing but a simple code.

A user needs to open the Chrome DevOps tool by pressing F12 or Ctrl+Shift+I on Linux and input the code mentioned below on the JavaScript code:

function KeepClicking(){

   console.log(“Clicking”);

   document.querySelector(“colab-toolbar-button#connect”).click()

}setInterval(KeepClicking,60000)

The figure 60,000 stands for the millisecond of a minute, so when the code is entered, it automatically makes a click on Colab after every 60 seconds. Thus, Colab assumes that the notebook is not kept idle and the user is still working. 

Custom Snippets

Whether a beginner or an expert, remembering code syntax can be a problem and may kill the desire to further work on a model. However, there is a way to skip the entire memorization process and get the job done easily by creating a snippet of the code.

A user can create custom snippets in Google Colab after creating a notebook. Once a notebook is created, one needs to add a text cell and type the name of the snippet. Below that, code cells are to be created, after which, one can type the code.

It is also possible to use snippets in multiple notebooks by following these steps:

  • Access Tools
  • Click on Settings

A pop-up box will appear where a user can paste the link of the notebook with snippets and click on Save.

Keyboard Shortcuts

Shifting from mouse to keyboard and vice versa leads to wastage of time. As a data scientist, it is imperative to increase productivity, which is not possible with mouse and keyboard at the same time. Keeping this in mind, Google Colab has come with several keyboard shortcuts which can help data scientists get the job done faster. Here is a list of keyboard shortcuts one can learn to avoid using a mouse.

Modes

This hack allows a user to view Google Colab in different avatars, which can be helpful in the longer run. Human eyes often get strained when it is exposed to the same colour for a long period. However, Google Colab comes with a dark mode, apart from the light mode, which is set by default. Even Jupyter Notebook misses out on this feature.

To get the dark mode, one needs to follow these steps:

  • Tools
  • Go to Settings
  • Click on Site
  • Select theme (Dark\Light)
  • Click on Save

That is not all as Colab has tried to be a little quirky with its Corgi and Kitty modes. In the Corgi mode, one can see puppies running on the Colab screen and in the Kitty mode, one can find kittens as is shown the pictures below:

Via Lynn Le

To get these, one needs to follow the steps mentioned below:

  • Go to Settings
  • Click on Miscellaneous
  • Select Corgi, Kitty or Both
  • Click on Save
Share
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India

Subscribe to Our Newsletter

The Belamy, our weekly Newsletter is a rage. Just enter your email below.