DEV Community

Cover image for Free online GPU resources for your next machine learning project
Ishaan Sheikh
Ishaan Sheikh

Posted on • Updated on • Originally published at

Free online GPU resources for your next machine learning project

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()))

Enter fullscreen mode Exit fullscreen mode

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

output of gpu enabled notebook

Oldest comments (2)

mattschwartz profile image
Matthew Schwartz

This might be really handy for experimenting improvements to my current project,

What's the lifetime of these notebooks? At what point does it make sense to switch to a paid service?

frikishaan profile image
Ishaan Sheikh

The training duration (session duration) of these notebooks are around 8-9 hrs, so if you model takes time more than that, you should consider paid service, also in order to get better GPU.