10 Google Collab Tips

--

Collab is my favorite place to do deep learning because:

  • No setup needed
  • Free
  • Faster than typical local setup
  • It is better than Kaggle and easier than Google Cloud.
  • Really good editor features.

Similar: Code better in Jupyter Notebook

1. Always Turn On Experimental Feature

Dynamically typed languages like Python are a pain (for me) because they do not provide good auto-complete. This is the best one I have seen so far.

2. ️ Jump to Definition

3. Use GUI for exploring files and Mounting Google Drive

Deep Learning is intimating enough.

You don’t want to remember everything as code. Use the GUI.

If a certain file you are looking for you can explore right click and click on copy path.

4. Creating Custom Snippets

You can add custom snippets by:

  1. Creating a collab notebook with a header followed by a snippet

2. Including it in your other notebooks by going to Tools -> Preferences and pasting URL of the custom notebook.

3. Search and use your snippet in code snippet section on the left

5. Get GPU Info

Type:

!nvidia-smi

If you have GPU mounted you will get this reply.

In case if you don’t know how to mount GPU:

Click RunTime Menu → Change RunTime→ Hardware Accelerator → Choose GPU

6. Opening Notebooks from Github with ease

To open a notebook from Github. Go to https://colab.research.google.com switch to the Github tab and enter an organization or URL.

A much easier way is to use “Open in Colab” Extension for Chrome

After installation, whenever you find a Jupyter notebook in Github, click the icon of the plugin and it will open in Colab.

7. Send email when the task is complete

This can be helpful when you want to leave your computer for a long time and want to just get a notification when training is completed.

This is a perfect candidate to apply with Tip #4.

import smtplibserver = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("sender_gmail_here@gmail.com", "your_password_here")
msg = "COLAB WORK FINISH ALERT!"
server.sendmail("sender_gmail_here@gmail.com", "receiver_gmail_here@gmail.com", msg)
server.quit()

Source: Colab Tricks by Rohit Midha

8.️ HyperDash

This one is more of an ML/DL DevOps tips which can work anywhere, even in other Jupyter notebook envs.

HyperDash allows you to monitor your model training or anything that is printed via your phone. It supports both iOS and Android and is super simple to get setup.

Installation Step:

  1. Install HyperDash on your phone

2. Go to your Jupyter notebook and run the below cell

I used GitHub login so I added -github in the end

!pip install hyperdash && hyperdash login — github

3. Import module

from hyperdash import monitor_cell

4. Use this magic in the cell you want to monitor. Which for most will be the training loop.

%%monitor_cell “model/experiment name”

In the app, you can see something like this. While I have included this as a tip, it is not something I have used. Because I have never trained for a very long duration.

App view

As per HyperDash website, it also allows detection of the status of your training and can notify when your training completes, fails, crashes or gets disconnected.

9. 10. — Random Filler Tips: Dark Mode and Corgi/Kitti Mode

This is kind of a filler tip. (Just because I wanted to round off to 10 tips 😜).

Go into Tools -> Preferences -> Theme -> Select dark.

While the dark mode is cool. I prefer using a light theme.

There is also a Corgi and Kitty mode under Miscellaneous which will add animated Corgis and Kitties in the header.

Other useful tips:

Previous: Code better in Jupyter Notebook

Next: How to Download Dataset from Kaggle

I respond to all my comments. ありがとう

--

--

Ankush Choubey: Full Stack Dev-Cloud/Microservices

25 y.o full stack developer from Mumbai who loves Full Stack Development and Deep Learning. Original Blog at ankushchoubey.com