Google Colab

You, web development
Back

By Aaron Gershkovich and Kosta Dubovskiy

What is Google Colab?

Google Colab is a unique IDE and programming tool. The IDE is hosted remotely in-browser, so you must work with internet connection by default. However, you can in fact host a local Colab runtime via a Jupyter notebook(the offline, locally-hosted inspiration for Colab). Generally, notebooks are used for scientific projects and experimentation.

Kernels

Colab makes use of kernels for modular programming. Kernels can be in any language usually, but Colab is built for Python. Kernels are like Lego bricks of code, where you can separate functional code from in-development code. The interface looks like this: 

Photo

The kernels are the rectangular blocks of text with the "[ ]" to the left of them. They're each run independently, but functions, variables, and imports are global.

This allows users to develop new code and deal with the errors without corrupting the rest of their code. It also helps with organization and making code readable when sharing it with others.

Virtual Machines(VM)

All of this is done on a virtual machine hosted by Google, so your files are interacted with through Google Drive and you need constant internet connection to work.

This has pros and cons. The primary pro is that you're working in a cleanly created Linux environment, which means your primary workhorse computer is safe from malware and overuse. The con is that Google is in control of your resources and they're not yet 100% clear on how the limits are decided and what's going on with your data(as Google always is).

Some notable VM-related features are:

  1. There's a built in terminal with sudo privileges(probably with limitations), but it's only usable through the upgraded Colab Pro+ subscription.
Photo
  1. Actual file system
Photo
  1. By default work is in the /content directory
  2. Limited disk space(~215 GB total). Clears after session.
  3. To Pro users, Google makes available GPU/TPU runtimes. Basically users can use either a GPU to run their code, or Google's proprietary Tensor Processing Unit(TPU) which is supposedly 15-30x faster than CPUs/GPUs for Machine Learning applications.
Photo

Also, although most libraries come pre-installed, since this is a standalone machine it is sometimes necessary to install libraries. This is relatively easy, but hard to do permanantly. You can install libraries in Python per usual with: !pip install nmap

Formats and Downloading Your Code

Because of the different format, notebook files are saved with a .ipynb extension rather than .py. These files can be opened and changed in any notebook IDE, like Jupyter Notebooks or Github Codespaces. However, you can also save your code as a python .py file of all the kernels frankensteined together. 

Cool Example Notebooks

Why Colab?

People choose Colab because it makes collaborating(get it?) on code much easier. Specifically, Colab makes machine learning projects easier to draft up and share with a colleague or just publish to the world at a publicly viewable, runnable IDE. Colab can also offer benefits to people who's home machines have poor CPUs/RAM/GPUs and need to run a VM to do any serious coding, and their Pro plans offer serious computational power at a very affordable price.

Colab, although not perfect, is very convenient, accessible, affordable, and good at what it's made to do.


Authors: Kosta Dubovskiy & Aaron Gershkovich

© Kosta Dubovskiy.RSS