Start Using Google Colab Free GPU

Since I published “Deep Learning with PyTorch is Not Torturing”, I have been asked for the best way to access free GPU to run deep learning. You can have a free GPU to run PyTorch, OpenCV, Tensorflow, or Keras. My recommendation is Google Colab. Two popular environments offer free GPU: Kaggle and Colab, both are of Google. I like Google Colab because it works seamlessly with my Google Drive. This post will walk you through how to set up a Google Colab account, how to connect GPU, and how to collaborate with your colleagues (that’s why it is called the Collaboratory).
Also, I’d like to mention this machine learning code generator App. It builds the app in Streamlit as the interface. This app can generate machine learning code in Colab, .py, or ipynb. If you are new to machine learning, the code is a good template to work on. And if you are looking for a nice way to build an app to share, Streamlit is a good choice.
(A) What Is Google Colab?
You may have installed Anaconda on your local machine and used the Jupyter notebook. If so, you will quickly learn to use Google Colab. Colab is a free Jupyter notebook environment that runs entirely in the cloud. There is no setup process. The notebooks that you create can be simultaneously edited by your team members — just the way you edit documents in Google Docs. Colab supports many popular machine learning libraries which can be easily loaded in your notebook. (At the end of the article, I also show you how to install Jupyter for both R and Python as an FYI.)
Google Colab already pre-installed libraries such as pandas, NumPy, Tensorflow, Keras, and OpenCV, so you do not need to run “pip install” by yourself. If you want to run OpenCV on Google Colab, scroll to the end of the article.
(B) How to Start?
The Google Colab works on your own Google Drive. Your first step is to create a folder for your Colab. I name my folder “Colab”. Open this folder. There is no content.



In the content area, right-click anywhere, and it shows the following drop-down menu. Because I have not installed “Colaboratory”, I do not see that selection.

Now click “+ Connect more apps” to search for “Colaboratory”:

You shall see this app. Install it. You shall go through the following steps.





Now right-click anywhere in the content area to open the drop-down menu, and you shall see “Google Colaboratory”:

When you click on it, a Colab Notebook comes up:

You can name your Colab Notebook. I name my notebook “My_first_DeepLearning.ipynb”.

(C) How to Set Up Free GPU?
Go to Edit > Notebook settings as the following:

Click on “Notebook settings” and select “GPU”. That’s it. You have a free 12GB NVIDIA Tesla K80 GPU to run up to 12 hours continuously for free. It is worth mentioning both Google Colab and Kaggle offer awesome GPU power.

(D) How to Upload a Dataset from Your Local Drive?
Run the following code (you do not need to pip install google.colab).














