Setting up Online Python Notebook

TRung Nguyen
5 min readJul 10, 2020

Introduction

The fastest way to learn something is to keep practicing. Play the whole game and learning soccer as a kid (Perkins).

Skip the Introduction and go to the Setting up Google Colab section.

When reading a scientific paper, sometimes you want to reproduce the results from the paper, or in your free time you just simply want to try something that interesting with AI application. However, you realize that running the code with your personal computer (laptop) will take a day or twos. As a result, your motivation might go down.

Luckily nowadays many big companies provide a basic online platform that fasts enough CPU and GPU for study purposes. It means you have the possibility to use the powerful computing platform (or rent with little cost) without the need for buying a new expensive computer. This document will show how to set up a few popular cloud computing platforms.

The term GPU computing or using GPU for Deep Learning might sound familiar and also might not. Why do we need GPU for deep learning? Let first makes the term a bit more clear.

CPU’s (Central processing unit) was designed as a general-purpose chip that can run any application on the desktop or server. At the most basic level, the CPU can process one task at a time. Raspberry Pi is an example of an embedded device with a strong CPU.

The GPU (Graphics processing unit)makes up for the deficiency in CPU architecture by adding thousands of CUDA cores and hundreds of Tensor cores, depending on the card, that can process thousands of tasks in parallel. NvidiaJetson is an example of a low-cost embedded device with a powerful GPU. However, for some like Google, the GPU is still too general-purpose to run workloads efficiently. Thus, Google has developed its own AI hardware known as the TPU (Tensor processing unit). Google describes the TPU as a “custom ASIC chip-designed from the ground up for machine learning workloads” and it currently runs many of its services like Gmail and Translates.

The NPU (Neural processing unit)is a specializes circuit that implements all the necessary control and arithmetic logic necessary to execute machine learning algorithms, typically by operating on predictive models such as artificial neural networks (ANNs) or random forests (RFs). NPUs sometimes go by similar names such as a tensor processing unit (TPU), neural network processor (NNP), and intelligence processing unit (IPU) as well as a vision processing unit (VPU).

TPU and NPUare more and more often use in embedded devices while GPUcomputing (especially NVidia GPU with Cuda cores) still dominant deep learning market for a next few years

Setting up Google Colab

Google Colab is Google’s collaborative version of the Jupyter notebook. They released the tool to the general public with a noble goal of dissemination of machine learning education and research[1]. Users need to sign up and apply for access before using the Colab. To help users get familiar with the environment google has provided a number of examples in the example tabs:

Colab interface

Select Connect on the right side of the notebook. Run the notebook by press” Shift-Enter”, ”Ctrl-Enter ” or through the run button.

Prepare the Notebook
Run the Notebook

Setting up GPU for Google Colab. Click the notebook setting and select GPU in the drop-down menu. Run the code to see how fast to use GPU compared with CPU.

Notebook setting
GPU VS CPU

Run a simple linear regression example using Colab to learn more. Select save a copy in the drive, then connect and run the notebook.

Save Copy in drive

Run Notebook with Kaggle

Kaggle is the world’s largest data science community with powerful tools and resources to help you achieve your data science goals[2]. After creating an account with Kaggle. Select the notebook tab and create a new notebook.

Creating a notebook with Kaggle

Enable GPU (only when necessary) and the internet using the setting tab. Kaggle only provides free 30 hours every week for GPU enabled.

Enable GPU with Kaggle

Try an example of a classification problem with Kaggle. Select copy and edit and then run the notebook example.

Example logistic regression notebook

Math and machine learning basics

There are many machine learning tutorials and online courses available for free/or paid from the Internet. One of the most famous online courses for the beginner is Machine Learning by Andrew.Ng from Coursera. There is also a git repository calls homemade machine learning which helps to practice and develop ”machine learning” algorithms from scratch for a better understanding of the mathematics behind each algorithm. In a git repository, each algorithm has been grouped in a section that included theory, code, and practicing notebook.

Example of a group section.

Click on the demo section an online Jupyter Notebook will open up a running example. Click on ” Execute on binder” to re-run the notebook.

Run notebook

Link to study resources

There are many more examples on Convolutional Neural Network (CNN), Recurrent Neural Networks (RNN) such as handwritten digits recognition, Shake-speare text generation,…etc on the link below.

Machine Learning Experiments.

Papers with code.

Python Data Science Handbook.

Pytorch Tutorial.

Popular Cloud Platform

Gradient.

Onepanel.

Floydhub.

Google Cloud Platform.

Microsoft Azure.

Amazon Sagemaker.

Amazon AWS.

Google Colab Pro.

References

[1]url:https://colab.research.google.com/notebooks/intro.ipynb#scrollTo=-Rh3-Vt9Nev9.

[2]url:https://www.kaggle.com/.

--

--