Link of this tutorial(Colab): https://reurl.cc/Epg3M0
Link of the class: https://www.youtube.com/watch?v=YmPF0jrWn6Y
Outline
Intro
What’s Colab? – Colab, or “Colaboratory”, allows you to write and execute Python in your browser with
- Zero configuration required
- Free access to GPUs
- Easy sharing
Getting Started
Creating a new cell
+Code: create a code cell
+Text: create a text cell
There are options for moving your cell up/down or copy or delete it.
Using an exclamation mark(!) starts a new shell, does the operations, and then kills that shell while percentage(%) affects the process associated with the notebook, and it’s called a magic command.
Use % instead of ! for cd(change directory) command
Other magic commands are listed here
Runtime Setting
Changing Runtime
To utilize the free GPU provided by google,
click on “Runtime” -> “Change Runtime Type” -> select “GPU“ for “Hardware Accelerator”
Doing this will restart the session, so make sure you change to the desired runtime before executing any code
Check GPU Type
Use the command nvida-smi to check the allocated GPU type
Available GPUs:
(But most of the time you get K80 using the free Colab)
File Manipulation
Download files via Google Drive
Upload and Download Files
Mounting Google Drive
if u want some files to be saved permantly, u can mount ur own google drive to colab and directly download/save the data to ur google drive
1 | from google.colab import drive |
Execute the following three code blocks in order
This will download the image to your google drive, and u can access it later
Saving Notebook
- Download the .ipynb file to ur local device (file > Download.ipynb)
- Save the colab notebook to your google drive (file > Save a copy in Drive)
- Convert .ipynb to .py and download (file > Download.py)
Useful Linux Commands(in Colab)
ls: List all files in the current directory
ls -l: List all files in the current directory with more detail
pwd: Output the working directory
mkdir
cd
gdown: Download files from google drive
wget: Download files from the internet
python
Problems
Colab will automatically disconnect if idle timeout(90 min., sometimes varying) or when your screen goes black
GPU usage is not unlimited! (ur account will be stopped for a period for a period if u reached the max gpu usage 12 hrs)
- Post title: Colab_Tutorial
- Create time: 2022-03-22 21:10:27
- Post link: Tutorial/colab-tutorial/
- Copyright notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally.