Get Started with Google Colab # Free GPU

Google Colab, A Free Cloud Service

If you are reading this post. One reason could be, you already start learning about machine learning or Artificial Intelligence, and now you are facing a problem. I am sure you might have run into the giant obstacle of — “Where to train my models?” .Your system takes a lot much time to train models. And even sometimes got blank when you are training data is huge.

Don’t worry, I personally go through this problem & I learn how to overcome it. Now it’s your turn.

Before talking further let me explain the specification of my system :

System Specificition

With no external GPU. With all given specification, it’s not possible to train AI and ML Models. But still, I am doing it.  For that I use many different services like

  • Google Colab
  • AWS
  • Google Cloud

All come down to free of cost.

In this post, I am gonna explain about Google Colab.

  1. What is Google Colab?
  2. How to use Google Colab.
  3. Using Google Colab, How you can develop deep learning application on the GPU the free.

What is Google Colab?

Google Colab is a free cloud service and now it supports free GPU & TPU! You can:

  • Improve your Python programming language coding skills.
  • Develop deep learning applications using popular libraries such as KerasTensorFlow, PyTorch, and OpenCV

The most promising fact of Google Colab is that: Colab provides GPU Services totally free of cost.

Some Frequently Asked Questions about Google Colab:  Clear up your doubts Before we begin.

What is Colaboratory?
Colaboratory is a research tool for machine learning education and research. It’s a Jupyter notebook environment that requires no setup to use.

What browsers are supported?
Colaboratory works with most major browsers and is most thoroughly tested with desktop versions of Chrome and Firefox.

Note:  I personally try to run Google Colab over different browsers-

  • Opera
  • Chrome
  • Firefox
  • Internet Explorer

Among all Chrome And Firefox are work’s best with Colab.

Is it free to use?
Yes. Colaboratory is a research project that is free to use.

What is the difference between Jupyter and Colaboratory?
Jupyter is the open source project on which Colaboratory is based. Colaboratory allows you to use and share Jupyter notebooks with others without having to download, install, or run anything on your own computer other than a browser.

How is this related to
In 2014 we worked with the Jupyter development team to release an early version of the tool. Since then Colaboratory has continued to evolve, guided by internal usage.

Where are my notebooks stored, and can I share them?
All Colaboratory notebooks are stored in Google Drive. Colaboratory notebooks can be shared just as you would with Google Docs or Sheets. Simply click the Share button at the top right of any Colaboratory notebook, or follow these Google Drive file sharing instructions.

If I share my notebook, what will be shared?
If you choose to share a notebook, the full contents of your notebook (text, code, and output) will be shared. You can omit code cell output from being saved or shared by selecting Edit > Notebook settings > Omit code cell output when saving this notebook. The virtual machine you’re using, including any custom files and libraries that you’ve setup, will not be shared. So it’s a good idea to include cells which install and load any custom libraries or files that your notebook needs.

What happens if two users edit the same notebook at the same time?
Changes are visible instantaneously to all users, in the same way Google Docs changes are automatically visible to all editors.

Can I import an existing Jupyter/IPython notebook into Colaboratory?
Yes. Choose “Upload notebook” from the File menu.

What about Python3? (or R, Scala, …)
Colaboratory supports Python 2.7 and Python 3.6. We’re aware that users are interested in support for other Jupyter kernels (eg R or Scala). We would like to support these, but don’t yet have any ETA.

How can I search Colaboratory notebooks?
Use Drive’s search box. Clicking on the Colaboratory logo at the top left of the notebook view will show all notebooks in Drive. You can also search for notebooks that you have opened recently using File->Open Recent.

Where is my code executed? What happens to my execution state if I close the browser window?
Code is executed in a virtual machine dedicated to your account. Virtual machines are recycled when idle for a while, and have a maximum lifetime enforced by the system.

How can I get my data out?
You can download any Colaboratory notebook that you’ve created from Google Drive following these instructions, or from within Colaboratory’s File menu. All Colaboratory notebooks are stored in the open source Jupyter notebook format ( .ipynb).

How may I use GPUs and why are they sometimes unavailable?
Colaboratory is intended for interactive use. Long-running background computations, particularly on GPUs, may be stopped. Please do not use Colaboratory for cryptocurrency mining. Doing so is unsupported and may result in service unavailability. We encourage users who wish to run continuous or long-running computations through Colaboratory’s UI to use a local runtime.

How can I reset the virtual machine(s) my code runs on, and why is this sometimes unavailable?
The “Reset all runtimes” entry in the “Runtime” menu will return all managed virtual machines assigned to you to their original state. This can be helpful in cases where a virtual machine has become unhealthy e.g. due to accidental overwrite of system files, or installation of incompatible software. Colaboratory limits how often this can be done to prevent undue resource consumption. If an attempt fails please try again later.

I found a bug or have a question, who do I contact?
Open any Colaboratory notebook. Then go to the Help menu and select ”Send feedback…”.

Hopefully, all the FAQs, clear up some doubts.

How to get started with Google Colab:

The first thing you need to start with Google Colab is Gmail Account: Sign in to Google Colab using Your Gmail Account.Sign up

Here you are, 1 more step to launch your first Google Colab Notebook. Move to-Google Colab code

Here we go. Launch our first Colab Notebook. Since Colab is working on your own Google Drive, So all the files you create will store in your Google Driver.

Now you are ready to write down all your code in the Notebook.

Google Cloud Use

Here we imported some Python libraries. It works as expected 🙂 If you do not know Python. The most popular programming language for AI.

Read more about Why Python is so popular for AI.

The coolest thing about Google Colab is that all major libraries (numpy, matplotlib, etc.) and frameworks (tensorflow, etc.) are pre-installed (just run “!pip freeze” to see the list of installed libraries and frameworks).

You do not need to go through various installation processes and, instead, can immediately proceed to write code. If any required library is missing, it can be installed with pip or apt.

Setting Free GPU to Colab notebook:

It is so simple to alter default hardware (CPU to GPU or vice versa); just follow Edit > Notebook settings or Runtime>Change runtime type and select GPU as Hardware accelerator.

Select GPU

Google colaboratory  offers the computing services of a Tesla K80 GPU & recently they start offering TPU, Which is 10x faster & expensive compared to GPU, for free. Yeah, you heard that right -“free”. The only catch here is that you can use the computing services for a maximum of 12 hours at a time.

Basically, when you train your models on the colaboratory, you are connected to a GPU-based virtual machine where you are given a maximum of 12 hours at a time, after which you lose access to that particular virtual machine instance (all data, that is, models parameters as well as datasets that aren’t saved to the Google drive before this period will be lost, so make sure to save snapshots of your model parameters at regular intervals, else you will have to start training your models from scratch again). After 12 hours you are assigned a different virtual machine (for free of course) and the cycle repeats. There’s no limit for how many virtual machines can be used through one account, so “Train” to your heart’s content.

About the author

Vikram singh

Founder of Ai Venture,
An artificial intelligence specialist who teaches developers how to get results with modern AI methods via hands-on tutorials.
GANs are my favorite one.

View all posts