This document provides an overview and tutorial of using Google Colab. It discusses:
- The speaker's background and experience in big data, AI, and machine learning
- An introduction to Google Colab and its key features like GPU/TPU acceleration and hardware limitations
- A tutorial on connecting to Colab, accessing files from Google Drive, and comparing CPU and GPU performance
- Examples of using Colab for flower classification with Keras and TPU as well as homework on iris classification
2. About me
• Education
• NCU (MIS)、NCCU (CS)
• Work Experience
• Telecom big data Innovation
• AI projects
• Retail marketing technology
• User Group
• TW Spark User Group
• TW Hadoop User Group
• Taiwan Data Engineer Association Director
• Research
• Big Data/ ML/ AIOT/ AI Columnist
2
6. Google CoLab
• A jupyter notebook based coding environment for python developer
and most popular python packages such like numpy, scikit-learn,
tensorflow, keras, pandas and matplotlib…
• It also supports hardware accelerate runtime for model building.
• GPU (Graphics Processing Unit): Nvidia K80, T4, P4 or P100
• TPU (Tensor Processing Unit): Cloud TPU | Google Cloud
• The notebook instance lasts 12 hours running and kernel session for 1
hour.
• Pay 9.99 USD/month choosing better plans (CoLab Pro or more)
• Plan price: Google Colab
6
7. Google CoLab
• Which One Do You Choose For Training Your Deep Neural Net?
7
Ref: https://www.predictiveanalyticsworld.com/machinelearningtimes/should-you-choose-a-gpu-or-a-tpu-to-train-your-machine-learning-models/10460/
check_colab_gpu_tpu.ipynb
8. Google CoLab
• Get a google account and use google drive service
• Launch a CoLab service
• Jupyter files repository
• Training, test dataset repository
• Model files repository
• Fast launcher with github repository ipynb file
8
9. Google CoLab
• CoLab limitation
• It can give you instances with 12GB of RAM and GPU for 12 hours (Max.) for
free use
• Save checkpoints during training to avoid time limitation
• Not for cryptocurrency mining
• Check CoLab FAQ
• More details: https://research.google.com/colaboratory/faq.html
• TPU price: https://cloud.google.com/tpu/pricing
9
16. Let’s started
• A new web jupyter notebook (has connected) called the runtime.
• Using web browser interacting with CoLab (jupyter notebook) called a
web session.
• Python running through python-kernel (runtime)
16
17. Let’s started
• Set auto-refresh CoLab webpage, avoid to have an idle timeout
• Press F12, run above code in console
• Don’t close the webpage until you won’t use it anymore
17
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
After executed, your CoLab webpage will sometime switch back working area
automatically in order to avoid the idle timeout
Ref: https://research.google.com/colaboratory/faq.html#idle-timeouts
18. Let’s started
18
File name and
configuration
Cell (coding area)
Session connection
Cell control
panel
Command palette (type logs or scratch or editor)
kernel running?
19. Let’s started
• Make a connection
19
Local runtime: https://research.google.com/colaboratory/local-runtimes.html
23. Let’s started
• Using cgroup to control
linux resources
• Check:
https://shekhargulati.co
m/2019/01/03/how-
docker-uses-cgroups-to-
set-resource-limits/
23
29. Other Topics
• Google Cloud Platform (GCP)
• https://cloud.google.com/
• CoLab integrates with BigQuery
• CoLab integrates with GCS (TPU only)
• To more fully use the parallelism, and to avoid bottlenecking on data transfer
29
30. Other Topics
• New features of CoLab
• Charts visualization
• Downloading Datasets into Google Drive via Google Colab
• https://towardsdatascience.com/downloading-datasets-into-google-drive-via-
google-colab-bcb1b30b0166
30
interacting_table.ipynb
colab_charts.ipynb
31. Flower classification
• The model will take as input a photo of a flower and return whether it
is a daisy, dandelion, rose, sunflower, or tulip.
• Using keras framework on TPU tensorflow 2.x.
31
The code is from: https://colab.research.google.com/notebooks/tpu.ipynb
tpu_colab.ipynb
32. Homework
• Try to create a iris classification project on colab follow the link
below.
• https://medium.com/@yosik81/machine-learning-in-30-minutes-
with-python-and-google-colab-6e6dfb77f5e1
32