Google Colab Free GPU !!! Yes you heard it right.

This article is about free GPU provided by google.

You can run any bash command in it by prefixing every command “!” and multiple commands by appending them by “&&” e.g.,

!ls
!mkdir images && cd images && wget https://website.com/images/DSC_0569.jpg

You can also mount your drive folder to it where you can save models, images and codes. Details can be found in this link

Every time you start a notebook the working directory is ‘/content’ . So at the beginning it is sugested to mount google drive folder every time you create a new jupyter notebook.

Mounting Process

Install the required software by running below command.

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

Mount your google drive

!mkdir -p drive
!google-drive-ocamlfuse drive

Or you can run any python script by

!python drive/train_script.py  #where 'drive/' folder is present in the root directory of your google drive.

Don’t forget to select GPU environment from Edit > Notebook Setting > GPU.

Reference: Google Colab Free GPU Tutorial
Written on February 8, 2018