Using Google Colab

https://d2l.ai/chapter_appendix-tools-for-deep-learning/colab.html

Using a GPU . Using a GPU is as simple as switching the runtime in Colab. Specifically, click Runtime -> Change runtime type -> Hardware Accelerator -> GPU and your Colab instance will automatically be backed by GPU compute.
from https://cs231n.github.io/setup-instructions/#installing-packages


Some normal operations

Run:

Pause:
image

Move( move your mouse to top right corner of any cells):
image

Has run:
image

Hasn’t run:
image
image

Restart(Ctrl+M):

Add code&text (move your mouse to middle of top or bottom edge of existing cells):
image

Another way (just add a cell below you are running): image

Delete:image

Find(Ctrl+G):


Switch code to md or reverselyimage

Keyboard shortcuts(Ctrl+M H):
image

[colab]read img: No such file: solved

git clone whole repo(include /img):

  1. Go to https://colab.research.google.com/

  2. Create a new notebook

image

  1. Mount it to your google Drive

image

  1. Create a new folder:

image

name it d2l-en:

image

  1. git clone : reference

%cd drive/My Drive/d2l-en

!git clone https://github.com/d2l-ai/d2l-en-colab.git

!git clone https://github.com/d2l-ai/d2l-pytorch-colab.git

!git clone https://github.com/d2l-ai/d2l-tensorflow-colab.git

The result is

mxnet repo: GitHub - d2l-ai/d2l-en-colab: Automatically Generated Notebooks for Colab

pytorch repo:GitHub - d2l-ai/d2l-pytorch-colab: Automatically Generated Notebooks for Colab

tensorflow repo:GitHub - d2l-ai/d2l-tensorflow-colab: Automatically Generated Notebooks for Colab

Delete a folder:


import shutil

shutil.rmtree('/content/drive/My Drive/d2l-en', ignore_errors=True)

More Tutorial

An issue I have: Still can’t open .ipynb file in my drive


read img

mount

image

run:

from google.colab import drive
drive.mount('/content/drive')


image

cd drive/My Drive/d2l-en/d2l-en-colab

!ls

!pwd

%cd drive/My Drive/d2l-en

%cd d2l-en-colab

imread

..img instead of .img

My code: colab or github
It applies to any imread or ·file control· if you have the matching repo to framework.


@mli, @astonzhang, @goldpiggy
Maybe you can get some help for all colab code to aviod this issue from 1:19:

PyTorch is already installed. Both the CPU and GPU should work: pytorch-latest-cpu

pytorch-latest-gpu

image
image

For more details on using PyTorch on Google Cloud, see:
https://cloud.google.com/deep-learning-vm/docs/images

from https://github.com/rmunro/pytorch_active_learning


!pip show d2l

https://course.fast.ai/start_colab is also helpful.