19 Sep Google COLAB – How to get started and work with it?
Google Colab or Colaboratory is a free cloud platform Machine Learning supported by Google. It allows its users to use free CPU and GPU services. It’s great for people and small scale companies working in Machine Learning but doesn’t have a GPU lying around. COLAB uses Jupyter Notebook files and does not require any kind of setup.
In this tutorial, we will teach you how to get started with Google Colab and start working with it. Let us see how to do this all!
Starting with Google COLAB
To start working with Google Colab, all you need is a Gmail account and Google Drive. To create your own Notebook go to Google COLAB.
Click the NEW NOTEBOOK. It will open up a new Jupyter Notebook file and it will be saved in your Google Drive in a folder called Colab Notebooks.
Working with Google COLAB
Once you have clicked on NEW NOTEBOOK, your browser will open the new notebook that you created. You can rename the file by clicking on the name of the file.
Colab is a completely virtual environment ready for your use. It supports Python 2.7 and Python 3.x and comes with most Python packages installed and ready to use. It is a shared resource, so possibilities are there that other people may be using the same CPU or GPU that you are using.
Connection with GPU
By default, when you create a new Notebook file, you are connected to a CPU with 12GB ram and 77 GB hard disk space. You can use this facility as long as you need it. If you need to connect to a GPU, go to Runtime > Change runtime type > Hardware accelerator. Change None to GPU and click SAVE. The environment will refresh and
You’ll be connected to the Tesla K80 GPU with 12GB Ram and 36 GB hard disk space. To check if a GPU is available, run this in the Notebook.
import tensorflow as tf tf.test.gpu_device_name()
If this output appears, then the GPU is working!
Connect with Google Drive
Notebook works in a virtual environment, once you close it or Factory Reset it, you will lose all of your data that you uploaded to your notebook. That’s why you need to connect your Google Drive with COLAB. You can use the data directly from the Drive and upload data and save your work from the Notebook.
To connect with your Drive, go to the side-bar and click the Google Drive button. It will create a new folder in your virtual environment called drive. The drive folder will contain all folders stored in your Google Drive.
COLAB Virtual Environment
The COLAB virtual environment is Linux based. The Code cells can take in Linux commands but are used slightly differently, some commands require “!” before them and some require “%”
!pip install numpy !cp /folder/file /folder/destination !ls %cd /folder/subfolder
Is this article helpful for you?
Don’t forget to visit our Blog for more interesting information like this one!