Web Hosting

How To Use Google Collab | What is Google Collab

What is Google Collab?

How To Use Google Collab

Google Colab is a free cloud service that currently supports GPU (Tesla K80) and TPU (TPUv2). Because it is developed on top of Jupiter Notebook, using Google Colab is very similar to using Jupyter Notebook. Google Colab is the perfect tool for us to practice programming skills with the Python language through deep learning libraries. Google Colab pre-installs for us very popular libraries in deep learning such as PyTorch, TensorFlow, Keras and OpenCV.

Machine Learning/Deep Learning is developing at a very fast pace. To write a program using a deep learning framework like TensorFlow, Kera or Pytorch, we can use any Python IDE like PyCharm, Jupyter Notebook or Atom. However, because machine learning/deep learning algorithms require systems with high speed and processing capability (usually based on GPUs), our computers are generally not equipped with GPUs.

Many learners and researchers choose to rent compute services on AWS as a solution.

Since then, Google has launched a completely free service for the AI research community developing deep learning applications by providing free GPUs and TPUs – that is Google Colab.

Currently, programmers often choose Colab over AWS’s high-cost service. Colab supports GPU (Tesla K80) and TPU (TPUv2). How to use Kolab It is similar to Jupyter Notebook. This is a great free service from Google if you don’t have a highly configurable computer to program and compile Python with deep learning libraries. Currently, Google Colab has popular libraries available to support research on artificial intelligence such as PyTorch, TensorFlow, Keras and OpenCV.

Google Colab is really cool. Apart from improving your coding skills, or working on Deep Learning PyTorch, Keras, TensorFlow, OpenCV libraries, you can also create notebooks on Colab, perform operations with those notebooks like upload, save store, Google Share on Drive too. You can use anything stored in your notebook to upload to your personal Jupyter, GitHub, Kaggle, and more.
Colab really provides the most amazing things a programmer needs when doing deep learning.
It is quite easy to do this on Google Colab. Google Colab is similar if you already use Jupyter Notebooks. And of course, you will feel the greatness of implementing Deep Learning on GPU-enabled software as compared to normal tight instructions.

Google Colab – Install on Google Drive

Create a folder for your notebook
(Technically, this step may not actually be necessary if you only need to work on Colab. However, since you use Google Colab on Drive, it wouldn’t be a bad idea to verify that Specify the folder where you want to work. You can do this by going to Google Drive, click “New” to create a new folder. I only mentioned this when I was having problems with my Google Drive and Millions of Colab notebooks were visible at the same time).
Alternatively, you can create a Colab notebook on your Google Drive. Just click on “New”, scroll down to the “More” section and select “Affiliates”.
Otherwise, you can directly go to Google Colab.
start up
You can rename your notebook by clicking on the name of the notebook and changing it directly, or by clicking “File” on the toolbar and scrolling down to the “Rename” section.
install gpu for free
When you want to use the GPU, it’s very simple. You need to click on “Runtime” on the toolbar, select the “Change runtime type” section and select GPU in the “Hardware Accelerator” section.

Start Code with Google Colab

start code
Now you can easily execute the code.
Improve with Google Colab
When you want to link Google Drive, you can do the following:
from google.colab import drive
drive.mount(‘/content/gdrive’)
Then you will see a link. Click on it and allow access. Copy the code that appears and paste it into the box, then press Enter. you are done. If you don’t see your drive in the left pane, just press “Refresh” and it will appear. Your result will have the following structure:

You should now be able to see your Drive on the left side of the screen. Plus, you can access your Drive at any time with:

!ls “/content/gdrive/My Drive/”

If you want to download a zip file you can use:

!wget 

!unzip

For example:

!wget -cq https://s3.amazonaws.com/content.udacity-data.com/courses/nd188/flower_data.zip

!unzip -qq flower_data.zip

With this command, you will have the data of the Udacity’s flower file almost immediately.

If you upload a small file, you can execute the upload command immediately with simple commands. Or alternatively you can look to the left side of the screen, click “ Upload files ”.

Google Colab is very simple to use. Especially when you are used to Notebook Jupyter. However, it may take some time if you have a large volume of files and have a few specific folders to work with.

Start Code

Now you can easily execute the code.

Improvements with Google Colab

When you want to link Google Drive, you can do the following:

from google.colab import drive

drive.mount(‘/content/gdrive’)

Then you will see a link. Click on it and allow access. Copy the code that appears and paste it into the box, then press enter. You are done. In case you don’t see your Drive in the left pane, just press “ Refresh ” and it will show up. Your result will have the following structure:

You should now be able to see your Drive on the left side of the screen. Plus, you can access your Drive at any time with:

!ls “/content/gdrive/My Drive/”

If you want to download a zip file you can use:

!wget 

!unzip

For example:

!wget -cq https://s3.amazonaws.com/content.udacity-data.com/courses/nd188/flower_data.zip

!unzip -qq flower_data.zip

With this command, you will have the data of the Udacity’s flower file almost immediately.

If you upload a small file, you can execute the upload command immediately with simple commands. Or alternatively you can look to the left side of the screen, click “ Upload files ”.

Upload files ”.

Google Colab is very simple to use. Especially when you are used to Notebook Jupyter. However, it may take some time if you have a large volume of files and have a few specific folders to work with.

Instructions for Importing Libraries in Google Colab

In most cases you can import libraries with the import command as you would in other software.

However, with PyTorch, before importing the library, you will have to run this command first:

# http://pytorch.org/

from os.path import exists

from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag

platform = ‘{}{}-{}’.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())

cuda_output = !ldconfig -p|grep cudart.so|sed -e ‘s/.*\.\([0-9]*\)\.\([0-9]*\)$/cu\1\ 2/’

accelerator = cuda_output[0] if exists(‘/dev/nvidia0’) else ‘cpu’

!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.4.1-{platform}-linux_x86_64.whl torchvision

import torch

Only then can you do import . But if you try to import torch without running the above command, you will get an error message. In this case, I strongly recommend clicking on the link that pops up. Once pressed, you will receive a code for you to install torch: “INSTALL TORCH” to your notebook. The code will appear on the left side of your screen, and then press “INSERT.”

Alternatively, you can perform the installation with the “pip install” command.

Note, on Colab, you need an exclamation point before most statements.

!pip install -q keras

import keras

Or:

!pip3 install torch torchvision

Or:

!apt-get install

also very helpful.

With Pillow you can get an error and it can be fixed by:

import PIL

print(PIL.PILLOW_VERSION)

In case you get anything below 5.3, run “runtime” in the toolbar. Restart the runtime and then continue to run the command.

You can easily create a new notebook by clicking “ File ”, clicking “ New Python 3 Notebook .” If you want to open a specific notebook, click “ File ”, then click “ Open notebook ”

You will see the following screen appear:

Wish you get acquainted and master Google Colab

Wish you get acquainted and master Google Colab

This Article Creating URLCJ and Phul4u

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button