September 15, 20245 minute read
How to get GPUs with a Jupyter notebook on Modal
author
Yiren Lu@YirenLu
Solutions Engineer

Over the years, Jupyter notebooks have evolved from simple coding environments to powerful platforms for complex data analysis, machine learning, and AI development. These applications often require significant computational power, making GPU acceleration a necessity.

However, the traditional approach of having dedicated GPU workstations or clusters comes with its own challenges:

  1. High upfront costs
  2. Underutilization during off-peak times
  3. Difficulty in scaling resources up or down based on project needs
  4. Maintenance and upgrade headaches

This is where the ability to spin up and down GPU resources on-demand becomes a game-changer.

In this guide, we show you how you can equip your Jupyter notebooks with flexible GPU resources provided by Modal’s serverless platform.

Enter Modal: On-Demand GPU-Powered Jupyter Notebooks

Prerequisites

Before we begin, make sure you have the following:

  1. An account at modal.com
  2. The Modal Python package installed (pip install modal)
  3. Authenticated with Modal (run modal setup or python -m modal setup if the former doesn’t work)

Instant GPU-Backed Notebooks

Launch a Jupyter notebook backed by Modal GPUs in seconds:

$ modal launch jupyter --gpu a10g

This single command provides you with a Jupyter instance backed by an NVIDIA A10G GPU, ready for your most demanding computations.

After running this command, you’ll see output similar to:

Jupyter on Modal, opening in browser...
    -> https://your-unique-url.modal.host/?token=your-secret-token

You can then open this URL in your web browser to access the Jupyter notebook.

For more advanced configurations, including other types of GPUs to attach to the notebook, you can refer to the Modal docs here.

Ship your first app in minutes

with $30 / month free compute