Google Colaboratory: Python in the Cloud

What, Why, and How

Bryan White
Jan 6, 2020 · 3 min read
Photo by Kelvin Ang on Unsplash

Google Colaboratory is a great platform for those who are:
- Looking to create a machine learning model but lack a strong enough CPU/GPU.
- Want the ease and simplicity that comes with a cloud based notebook which requires no setup.

So, What is Google Colaboratory, and Why Should I Use It?

Simply put, Google Colab is a free to use, cloud based version of a Jupyter notebook where the only requirement is a web browser.

Your code is run on a virtual machine hosted by Google, so you don’t need to rely on your PC’s CPU or GPU for any of the heavy lifting, thus making Colab perfect for running intensive machine learning models at no cost.

As the name would suggest, Colab is great for teams to be able to work on scripts simultaneously, as it has the same shared document editing that we are used to from Google Docs.
Notebooks are saved on Google Drive and can be easily revisited for editing or sharing.

A free to use GPU makes Colab a no-brainer; even if not the most powerful around, it makes for a great platform on which to build and develop your machine learning skills.

Colab Hardware Specs

Photo by Cristiano Firmani on Unsplash

For those curious about just what you get access to, by running the following code in Colab you can query the system specs.

GPU Count and Name:
(Ensure you go to Runtime > Change Runtime Type > GPU)

CPU Model/Sockets/Cores/Threads/Cache/Frequency:

RAM and HD Space:

Tools for Getting Started

Photo by Hunter Haley on Unsplash

There are a few differences between Colab and a traditional Jupyter notebook. Being cloud based, there are some slight variations on installing packages and importing data.

Installing a package is as easy as prefacing your usual pip command with a !

Importing files to use can be done in one of several ways.

Clone from Github:

Upload a File:

Mount Google Drive:

From there, you can view the contents of your drive by typing :

And with that you have all the tools needed to start your cloud-based ML adventure!

It is important to note that the virtual machine that you run your code on will be recycled by Google when idle for a certain amount of time (i.e., overnight).
Furthermore, the VM that is being used — including any added files or packages — won’t be shared, so the team at Colab very smartly suggest that you include cells which install and load any custom libraries or files.

Happy coding!

Photo by bruce mars on Unsplash

The Startup

Get smarter at building your thing. Join The Startup’s +799K followers.

Bryan White

Written by

Supply Chain Analyst and Data Science Student at the University of Auckland.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +799K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store