Colab Tricks

Author: Jimut Bahan Pal

0. USE GPU, TPU's doesn't works


1. To increase RAM, Disk and probably GPU (very erratic, probably doesn't work now)


2. To never stop colab running, Source: stackoverflow

Google Colab notebooks have an idle timeout of 90 minutes
and absolute timeout of 12 hours. This means, if user does not 
interact with his Google Colab notebook for more than 90 
minutes, its instance is automatically terminated. Also, maximum 
lifetime of a Colab instance is 12 hours.

JavaScript Code

Web-Developer -> Console -> paste
function ConnectButton(){
    console.log("Connect pushed"); 
    document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,600000); //600 seconds

3. Mounting Drive and Shell Scripts

Mounting drive

Currently, no option to mount multiple drives


4. Git clone, Bandwidth : 100 MBPS

simple shell commands

cannot change directory with !

Use only shell command to change directory

More I/O stuffs here https://colab.research.google.com/notebooks/io.ipynb


5. Downloading data from Kaggle-Brain-MRI-Seg without API

Use the updated Token always


Install gdown https://github.com/wkentaro/gdown

https://drive.google.com/file/d/1vNsxAMmQzgCrA2A2ZrRrm6E8q14Y_c0D/view?usp=sharing

7. Open Any notebook on the fly from Github

https://github.com/Jimut123/CAPTCHA

https://github.com/Jimut123/CAPTCHA/blob/master/download_Project.ipynb

add a https://colab.research.google.com/github/

https://colab.research.google.com/github/Jimut123/CAPTCHA/blob/master/download_Project.ipynb


8. Cloning a Private Repo [ML2Proj]

https://stackoverflow.com/questions/48350226/methods-for-using-git-with-google-colab


9. GPU info

10. Send mails when Task is complete

https://github.com/Jimut123/spammify


11. Know the RAM and GPU memory used by Colab

use printm()


Just a modified version of the same thing.. shows the stats after 1 sec, or specified amount of time.