Google Colaboratory Cheat Sheet

Rahul Metangale
2 min readMar 27, 2018

Google colaboratory recently started offering free GPU. Colaboratory has become my goto tool to develop and test deep learning models. I usually develop and test my models on Google Colaboratory before doing full training and testing on AWS GPU instance.

When i was exploring this tool initially i had many questions like how do i download my project from github to colob? how to download data set? where it get stored? etc hence in this blog post i will answer some of these question so that others can benefit from this. BTW this is my first Medium post!

Please note that data downloaded into colab is stored in temporary store so it will be lost when you close your browser or when runtime is restarted. I don’t see this as a problem because data can be downloaded again quickly in colab.

  1. Cloning GitHub repository:
!git clone <GitHub repo url>
#example: !git clone https://github.com/udacity/dog-project.git

Above command will clone github repository on colab temporary storage.

2. Then you can run following command to CD into directory:

%cd <folder name>

3. To see contents of folder you can run following command:

!ls

4. To install missing python packages you can run pip command as follows:

!pip install tqdm
#Where tqdm is the package name

5. To download files you can run following command:

!wget <path to file>

example:

!wget https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/dogImages.zip

6. To create folder run following command:

!mkdir <folder name>

7. To remove folder , subfolder and files run following command:

!rm -rf <folder name>

8. To upload file to Google colab temporary store run following command

from google.colab import files
uploadedFile = files.upload()

I did face memory issues and runtime crashes while i was trying to train the model with large dataset. I was able to overcome these issue by :

a. Using subset of data for training

b. Use pickle or h5py to serialise and deserialize data along with following command to release the memory

%reset -f -s

I hope you find this useful.

--

--

Rahul Metangale

Cloud Solutions Architect | GIS expert | Deep Learning enthusiast