This is supposed to be a concise tutorial and you should not spend longer than 10 minutes to go through it.
Google Colab is a free Jupyter notebook that requires no setup to use. It works with most major browsers. As written in the faq of Colaboratory, it has been tested with the latest versions of Chrome, Firefox, and Safari.
All Colab notebooks are stored in Google Drive. They can be shared just as you would do in Google Docs, etc. -- simply click the Share button on any Colab notebooks.
If a notebook is shared, the whole contents will be shared i.e. text, code, and outputs. However, you can omit to share outputs by selecting Edit > Notebook settings > Omit code cell output when saving this notebook. The virtual machine you are using, including any custom files and installed libraries, will not be shared. Hence, it is always a good idea to include cells which can install what the notebook needs.
Yes, you can import it by choosing Upload notebook from the File menu.
You can download any Colab notebook that you have created from Google Drive or from Colab's File menu. All Colab notebooks are stored in the Jupyter notebook format (.ipynb).
Simply click Edit > Notebook settings or Runtime > Change runtime type. Then, select either GPU or TPU as Hardware accelerator.
!ls "/content/drive/My Drive/"
!wget https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/Titanic.csv -P "/content/drive/My Drive/app"
2. To read the file and display first 5 rows, you may use pandas.
import pandas as pd
titanic = pd.read_csv(“/content/drive/My Drive/app/Titanic.csv”)
titanic.head(5)
Simply use !pip install
or !apt-get install
.
To see if you are using GPU in Colab, you can run the following commands. See this Colab notebook as an example for TPU checking.
import tensorflow as tf
tf.test.gpu_device_name()
Simply run the following command:
from tensorflow.python.client import device_lib device_lib.list_local_devices()
!cat /proc/meminfo
!cat /proc/cpuinfo
Run the following commands:
import os
os.chdir("drive/app")
Here, the working directory will be set to "drive/app" and you don't need to add "drive/app" anymore to access files.
If you encounter the following error:
Failed to assign a backend
No backend with GPU available.
Would you like to use a runtime with no accelerator?
This means a lot of people are using GPUs now. You should try using it a bit later.
Follow Tools > Command Palette > Clear All Outputs
Form makes tuning hyperparameters easier from directly changing them in the code. To add a Form in a cell, simply click +form on that cell (as shown on the figure).
To see function arguments, simply add question mark (?) after the function name. For instance, the figure illustrates to display TensorFlow's documentation without opening its website.
This tutorial is summarized and is revised from:
Other blogged posts >> Tutorials