Learn whether iPython, Jupyter Notebook, and Google Colab are Rivals or Complimentary Tools; Understand Their Relationship
Colaboratory, or Colab for short, is a Google Research product, which allows developers to write and execute Python code through their browser. Google Colab is an excellent tool for deep learning tasks. It is a hosted Jupyter notebook that requires no setup and has an excellent free version, which gives free access to Google computing resources such as GPUs and TPUs.
In this post, we will cover three topics:
1 — Interactive Python Programming Environments: Python, Jupyter Notebook, and Google Colab;
2–4 Additional Features of Google Colab over Jupyter Notebook; and
3 — How to Create a Google Colab Notebook in 5 Easy Steps.
Since Google Colab is built on top of vanilla Jupyter Notebook, which is built on top of Python kernel, let’s look at these technologies before diving into why we should and how we can use Google Colab.
Please note that this is not a sponsored post. I am sharing my views on a product that I have been using for years.
Interactive Programming Environments
There are several tools used in Python interactive programming environments. The central technology making interaction possible is iPython. IPython is an improved shell and read–eval–print loop (REPL) for Python.
A read–eval–print loop (REPL) is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.
“iPython Notebook” is a product developed with iPython accessed as a “notebook” via a web browser. IPython handles two fundamental roles:
- The Terminal IPython as a REPL; and
- The IPython kernel, which provides computation and communication with the frontend interfaces such as iPython notebook.
Developers can write codes, take notes, and upload media to their iPython notebook. The growth of the iPython notebook project led to Project Jupyter, which contains the notebook tool and the other interactive tools for multiple languages (Julia, Python, and R). Jupyter Notebook and its flexible interface extend the notebook beyond code to visualization, multimedia, collaboration, and many other features, which creates a comfortable environment for data scientists and machine learning experts.
Let’s get into a more detailed analysis of iPython, Jupyter Notebook, and Google Colab.
iPython is a command shell and a kernel, which powers interactive Python notebooks. iPython allows programmers to run their code in a notebook environment quickly. The features that iPython provides can be summarized as follows:
- Interactive shells (Terminal and Qt Console).
- A web-based notebook interface with support for code, text, and media.
- Support for interactive data visualization and GUI toolkits.
- Flexible and embeddable interpreters to load into projects.
- Parallel computing toolkits.
iPython Project has grown beyond running Python scripts and is on its way to becoming a language-agnostic tool. As of iPython 4.0, the language-agnostic parts are gathered under a new Project, named Project Jupyter. The name Jupyter is a reference to core programming languages supported by Jupyter, which are Julia, Python, and R. As of the implementation of this spin-off decision, iPython, now only focuses on interactive Python whereas Jupyter focuses on tools like the notebook format, message protocol, QT Console, notebook web application.
Project Jupyter is a spin-off open-source project born out of the iPython Project in 2014. Jupyter is forever free for all to use, and it is developed through the consensus of the Jupyter community. Several useful tools are released as part of the Jupyter Project, such as Jupyter Notebook, JupyterLab, Jupyter Hub, and Voilà. While all these tools may be used simultaneously for accompanying purposes, installing Jupyter Notebook suffices the environmental requirements for a basic machine learning project.
On the other hand, as an open-source project, Jupyter tools may be integrated into different toolsets and bundles. Instead of installing Jupyter Notebook through Terminal (for macOS and Linux) or Command Prompt (for Windows), you can use the Anaconda distribution, which will also take care of the environment installation on local machines.
If you want to take your development experience to the next level, Google Colab, which is a cloud-based Jupyter Notebook environment, is the ultimate tool.
Let’s see why:
Why Should I Use Google Colab?
There are several reasons to opt to use Google Colab instead of a plain Jupyter Notebook instance:
- Pre-Installed Libraries
- Saved on the Cloud
- Free GPU and TPU Use
Let’s see these advantages in more detail:
Anaconda distribution of Jupyter Notebook shipped with several pre-installed data libraries, such as Pandas, NumPy, Matplotlib, which is awesome. Google Colab, on the other hand, provides even more pre-installed machine learning libraries such as Keras, TensorFlow, and PyTorch.
Saved on the Cloud
When you opt to use a plain Jupyter notebook as your development environment, everything is saved in your local machine. If you are cautious about privacy, this may be a preferred feature for you. However, if you want your notebooks to be accessible to you from any device with a simple Google log-in, then Google Colab is the way to go. All of your Google Colab notebooks are saved under your Google Drive account, just like your Google Docs and Google Sheets files.
Another great feature that Google Colab offers is the collaboration feature. If you are working with multiple developers on a project, it is great to use Google Colab notebook. Just like collaborating on a Google Docs document, you can co-code with multiple developers using a Google Colab notebook. Besides, you can also share your completed work with other developers.
For me this is a great option since I share all my Colab notebooks with my subscribers thanks to this feature. Subscribe today to get them!
Free GPU and TPU Use
I think this is an absolute no brainer to choose Google Colab instead of a local Jupyter notebook. Google Research lets you use their dedicated GPUs and TPUs for your personal machine learning projects. Speaking from experience, for some projects, the GPU and TPU acceleration make a huge difference even for some small projects. This is one of the main reasons for me to code all my educational projects on Google Colab. Besides, since it uses Google resources, the neural network optimization operations do not mess with my processors, and my cooling fan doesn’t go crazy.
Google Colab is just a specialized version of the Jupyter Notebook, which runs on the cloud and offers free computing resources. The relationship between iPython, Jupyter Notebook, and Google Colab is shown in Figure 3.
So, I assume that you are now convinced that you will use Google Colab for your next project. How are you going to set it up?
It’s fairly simple:
Google Colab Setup
The Google Setup process is relatively easy and can be completed with the following steps across all devices:
- Visit the Google Colab page, which will direct you to the Google Colaboratory Welcome Page.
2. Click the Sign in button on the right top.
3. Sign in with your Gmail account. Create one if you don’t have a Gmail account.
4. As soon as you complete the sign-in process, you are ready to use Google Colab.
5. You may easily create a new Colab notebook on this page by clicking File> New notebook.
You have successfully created a Google Colab notebook within minutes. Now you can start working on your machine learning project.
In this post, we talked about three complementary interactive programming environments. iPython provides a useful kernel to run interactive codes. Jupyter Notebook provides a beautiful notebook with cells that you can add code, media, and text. Finally, Google Colab adds collaboration, free GPU and TPU, cloud features, and additional pre-installed ML libraries.
I can think of two scenarios where you should opt for a local Jupyter Notebook instance:
1 — If you care about privacy and want to keep your code hidden, stay away from Google Colab; or
2 — If you have an incredibly powerful local machine with access to GPUs and TPUs, also local Jupyter Notebook is the way to go.
But, for almost all the other scenarios, I’d recommend Google Colab. I hope this post was helpful in understanding the relationship between iPython, Jupyter Notebook, and Google Colab notebook.