The training phase in machine learning is a resource-intensive task, which needs a lot of computation power.

A GPU (Graphics Processing Unit) is a specialized electronic circuit designed to perform mathematical calculations faster than CPU in order to render images or graphics.

If you are familiar with some machine learning algorithms, you have seen that training is just finding the best possible weights(numbers) which can fit the data well.

In this post, I’ll share two resources you can use to train your machine learning model faster on cloud GPUs for free.

1. Google Colab

Google Colab is one of the free resources available out there. It provides a free Jupyter Notebook environment in the cloud with Tesla K80 GPU. However, GPU is not enabled by default. To enable GPU goto Edit > Notebook Setting and select GPU from the options.

google colab enabling gpu

It also provides features like importing and exporting data directly into your Google drive.

2. Kaggle Notebooks

Kaggle is an online community of data scientists and machine learning practitioners. The website hosts many competitions throughout the year. It also provides a cloud environment for data science and machine learning with Tesla P100 16GB GPU.

To enable GPU you have to select an accelerator during the creation of a new notebook or by clicking the three dots on the top-right corner of the notebook.

enabling GPU in kaggle notebooks

enabling GPU in kaggle notebooks

Code to test if GPU is enabled

Run the following code to test if the GPU is enabled in your environment.

import torch

print("Current device :{}".format(torch.cuda.current_device()))

print("Device count :{}".format(torch.cuda.device_count()))

print("Device name :{}".format(torch.cuda.get_device_name(0)))

print("Device available :{}".format(torch.cuda.is_available()))

If the GPUs are enabled you’ll the output something like below

output of gpu enabled notebook