# Running Jupyter on a GPU for data science experiments



Learn how to set up and optimize a Jupyter Notebook environment on high-performance GPUs for interactive data science and ML experiments.



Workflows · 2026-07-14 · 4 min read



Data science experiments thrive on interactivity. Whether you are fine-tuning a BERT model, exploring a new generative architecture, or processing massive dataframes with RAPIDS, the feedback loop of a Jupyter Notebook is indispensable. However, local environments rarely provide the VRAM needed for modern workloads, and managing persistent, expensive instances can drain budgets quickly.

In this guide, we will walk through the process of setting up a Jupyter environment on a high-performance GPU, optimizing it for performance, and leveraging a per-second billing model to keep experimentation costs low.

## The Challenge of GPU-Accelerated Notebooks

Setting up a Jupyter environment for ML isn't just about installing a package. You need to ensure the underlying drivers (CUDA), libraries (cuDNN), and the Python kernel are all synchronized. Furthermore, when running experiments in the cloud, you face a trade-off: keeping an instance running all day is expensive, but shutting it down often means losing your progress or spending 20 minutes re-configuring your environment.

The ideal workflow involves launching a containerized environment where all dependencies are pre-baked, allowing you to jump straight into the code.

## Step 1: Preparing Your Environment

To follow this guide, you will need the Podstack API and your API key. If you haven't installed the API yet, you can do so via pip:

```text
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
```

The API allows you to spin up on-demand GPU resources that bill you only for the seconds the notebook is actually running.

## Step 2: Selecting the Right Container Image

For data science, using a raw Ubuntu image is inefficient. It is better to use an image optimized for GPU compute. The `pytorch/pytorch` or `tensorflow/tensorflow` images are standard, but for a full Jupyter experience, images from the **Jupyter Docker Stacks** with GPU support are preferred.

## Step 3: Launching the Jupyter Job

On a serverless GPU cloud like Podstack, you can launch a Jupyter instance as a persistent job. This allows you to map a local port to the remote GPU instance so you can access the notebook in your local browser.

Run the following command to start an NVIDIA A100 or L40S instance:

```text
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
```

*Note: In a production or shared environment, always set a secure token for your NotebookApp.*

## Step 4: Connecting and Running Code

Once the job is active, Podstack provides a tunnel or a public URL to access your port. Open your browser to the provided address, and you are ready to verify your GPU access.

In your first cell, run this snippet to confirm that your notebook is correctly utilizing the hardware:

```python
import torch
import sys

def check_gpu():
    if torch.cuda.is_available():
        gpu_name = torch.cuda.get_device_name(0)
        vram = torch.cuda.get_device_properties(0).total_memory / 1e9
        print(f"✅ Success! Connected to: {gpu_name}")
        print(f"📊 Available VRAM: {vram:.2f} GB")
    else:
        print("❌ GPU not detected. Check your drivers and image.")

check_gpu()
```

## Practical Tips for GPU Data Science

1.  **Monitor VRAM in Real-time:** Open a terminal within Jupyter and run `watch -n 1 nvidia-smi`. This helps you identify memory leaks or instances where your batch size is too large before you hit an "Out of Memory" (OOM) error.
2.  **Persistent Storage:** Data science experiments often involve large datasets. Instead of downloading them every time, mount a persistent volume to your Podstack job. This ensures that your `/home/jovyan/work` directory survives even after the GPU instance is spun down.
3.  **Use Kernel Restarts:** GPU memory can sometimes get fragmented or fail to release after a heavy training run. If `torch.cuda.empty_cache()` doesn't work, restarting the Jupyter kernel is the cleanest way to reset the VRAM state.

## Scaling from Notebook to API

Interactive experimentation is just the beginning. Once your model architecture is finalized in Jupyter, the next step is moving toward production. The transition from a `.ipynb` file to a scalable endpoint is where most friction occurs.

With Podstack, you can take the logic you developed in your notebook and wrap it in a Python GPU function. Instead of managing a persistent server, you can deploy your inference code as a serverless endpoint that only triggers when a request arrives.

## Conclusion

Running Jupyter on a GPU shouldn't be a configuration headache. By using containerized environments and on-demand GPU provisioning, you can focus on your data instead of your infrastructure. 

Podstack makes this workflow seamless by offering high-end GPUs like the H100 and A100 on a per-second billing basis. You can spin up a powerful environment for a quick experiment, run your cells, and shut it down immediately, ensuring you only pay for the compute you actually used. 

Ready to start? Head over to your terminal, set your `PODSTACK_API_KEY`, and launch your first accelerated notebook in seconds.
