Introduction to using google colab
- 1. خدا نام به
Google colab
A Classroom presentation on
Cloud Computing at Tarbiat
Modarres University
presentation by:
Ali Sarvary
Ali Alemi
Instructor: Sadegh Dorri N.
Fall 2018 (1397-98)
- 3. What is Google Colab?
Google Colab is a free cloud service and now it supports free GPU!
improve your Python programming language coding skills.
develop deep learning applications using popular libraries such as
Keras, TensorFlow, PyTorch, and OpenCV.
The most important feature that distinguishes Colab from other free
cloud services is; Colab provides GPU and is totally free.
Details: https://research.google.com/colaboratory/faq.html
- 4. What is Google drive?
Google Drive is a file storage and synchronization service
developed by Google.
Google Drive allows users to store files on their servers,
synchronize files across devices, and share files.
Google Drive offers users with 15 gigabytes of free storage
through Google One.
Files uploaded can be up to 5 terabytes in size.
- 5. Getting Google Colab Ready to Use
Since Colab is working on your own Google Drive, we first need to
specify the folder we’ll work.
Of course, you choose the default Colab Notebooks folder instead
of app folder.
- 6. Creating New Colab Notebook
Create a new notebook via Right click > More > Colaboratory
- 8. Setting Free GPU
It is so simple to alter default hardware (CPU to GPU or vice
versa); just follow Edit > Notebook
settings or Runtime>Change runtime type and select
GPU as Hardware accelerator.
- 10. Running or Importing .py Files with Google Colab
Run these codes first in order to install the necessary libraries and perform
authorization.
from google.colab import drive
drive.mount(‘/content/drive/)
When you run the code above, you should see a result like this:
Click the link, copy verification code and paste it to text box.
- 11. Running or Importing .py Files with Google Colab
After completion of the authorization process, you should see this:
Now you can reach your Google Drive with:
!ls "/content/drive/My Drive/"
- 12. Cloning Github Repo to Google Colab
It is easy to clone a Github repo with Git.
Step 1: Find the Github Repo and Get “Git” Link
Find any Github repo to use.
Clone or download > Copy the link!
Step 2: Git Clone
Simply run:
Step 3. Open the Folder in Google Drive
Folder has the same with the Github repo of course
!git clone https://github.com/wxs/keras-mnist-tutorial.git
- 13. Cloning Github Repo to Google Colab
Step 4. Open The Notebook
Right Click > Open With > Colaboratory
Step 5. Run
Now you are able to run Github repo in Google Colab.
- 14. Is GPU Working?
To see if you are currently using the GPU in Colab, you can run the
following code in order to cross-check:
import tensorflow as tf
tf.test.gpu_device_name()
- 15. Which GPU Am I Using?
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
Currently, Colab only provides Tesla K80.
- 19. How to Restart Google Colab?
In order to restart (or reset) your virtual machine, simply run:
!kill -9 -1
- 20. How to Send Large Files From Colab
To Google Drive?
Editor's Notes
- Keras : open source library for network
Pytorch: open source library for ML
Open CV: open source library of intel for function programming
به طور پیشفرض Tensorflow و بسیاری از کتابخانههای دیگر مثل numpy و sklearn و… روی آن نصب شده است و شما میتونید به پیادهسازی مدلهاتون بپردازید.
- Google one:provide100 gigabytes, 200 gigabytes, 2 terabytes, 10 terabytes, 20 terabytes, and 30 terabytes
- App folder in drive
- به راحتی میتونید در کولب دستورهای مختلف از جمله pip , apt-get, ls, cd, و… را اجرا کنید. فقط کافی است قبل از دستور مورد نظرتون علامت ! رو قرار بدهید.