> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vessl.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GPU-accelerated notebook

> Launch a Jupyter Notebook server with an SSH connection

This example deploys a Jupyter Notebook server. You will also learn how you can connect to the server on VS Code or an IDE of your choice.

<Note>
  Note that if you want to save your credits, remember to **Terminate** to stop
  and end the runs.
</Note>

## What you will do

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/notebook-title.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=5d3c5036b287c9d5775b55ee61d7b109" width="3204" height="2404" data-path="images/get-started/notebook-title.png" />

* Launch a GPU-accelerated interactive workload
* Set up a Jupyter Notebook
* Use SSH to connect to the workload

## Writing the YAML file

Let's start by creating `notebook.yaml` file and fill it in.

<Steps titleSize="h3">
  <Step title="Spin up a workload">
    Let's repeat the steps from [Quickstart](/guides/get-started/quickstart) and define the compute resource and runtime environment for our workload. Again, we will use the L4 instance from our managed cloud and the latest PyTorch container from NVIDIA NGC.

    ```yaml theme={null}
    name: Jupyter notebook
    description: A Jupyter Notebook server with an SSH connection
    resources:
      cluster: vessl-oci-sanjose
      preset: gpu-a10-small
    image: quay.io/vessl-ai/torch:2.3.1-cuda12.1-r5
    ```
  </Step>

  <Step title="Configure an interactive run">
    By default, workloads launched with VESSL Run are batch jobs like the one we launched in our Quickstart example. On the other hand, interactive runs are essentially virtual machines running on GPUs for live interaction with your models and datasets.

    You can enable this with the `interactive` key, followed by the `jupyter` key. Interactive runs come with a default field for idle culler which automatically shuts down user notebook servers when they have not been used for a certain period.

    `max_runtime` works with `idle_timeout` as an additional measure to prevent resource overuse

    ```yaml theme={null}
    name: Jupyter notebook
    description: A Jupyter Notebook server with an SSH connection
    resources:
      cluster: vessl-oci-sanjose
      preset: gpu-a10-small
    image: quay.io/vessl-ai/torch:2.3.1-cuda12.1-r5
    interactive:
      jupyter:
        idle_timeout: 120m
      max_runtime: 24h
    ```
  </Step>
</Steps>

## Running the workload

Now that we have a completed YAML, we can once again run the workload with `vessl run`.

```
vessl run create -f notebook.yaml
```

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/notebook-run.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=241321b3af6d862feda5b4e137b53ae3" width="1365" height="918" data-path="images/get-started/notebook-run.png" />

Running the command will verify your YAML and show you the current status of the workload. Click the output link in your terminal to see the full details and realtime logs of the **Run** on the web. Click **Jupyter** under **Connect** to launch a notebook.

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/notebook-workspace.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=6526cdac9eb8cfff426901d8faeebc40" width="1176" height="848" data-path="images/get-started/notebook-workspace.png" />

<img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/notebook-jupyter.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=d2b5df2745ea0f5e9e5f924fb6758ee6" width="1917" height="966" data-path="images/get-started/notebook-jupyter.png" />

## Create an SSH connection

An interactive run is essentially a GPU-accelerated workload on a cloud with a port and an endpoint for live interactions. This means you can access the remote workload using SSH.

<Steps>
  <Step title="Get an SSH key pair">
    First, get an SSH key pair.

    `ssh-keygen -t ed25519 -C "vesslai"`

    <img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/gpu-notebook_ssh-keygen.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=0726a85bab8d31099e675dd17ffa3d94" width="2544" height="1132" data-path="images/get-started/gpu-notebook_ssh-keygen.png" />
  </Step>

  <Step title="Add the generated key to your account">
    `vessl ssh-key add`

    Press "enter" three times.

    <img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/gpu-notebook_ssh-add.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=d412f79d136ed6fd3484647a33d59635" width="2544" height="436" data-path="images/get-started/gpu-notebook_ssh-add.png" />
  </Step>

  <Step title="Connect via SSH">
    Use the workload address from the **Run Summary** page to connect. You are ready
    to use [VS Code](https://code.visualstudio.com/docs/remote/ssh) or an IDE
    of your choice for remote development.

    <img style={{ borderRadius: '0.5rem' }} src="https://mintcdn.com/vesslai/q8PNhBb-7_q5awBv/images/get-started/notebook-ssh-info.png?fit=max&auto=format&n=q8PNhBb-7_q5awBv&q=85&s=35a81818401628ab1a09fceb66cd1a98" width="1177" height="827" data-path="images/get-started/notebook-ssh-info.png" />
  </Step>
</Steps>

<Note>
  **Manual access:** The below command for manual access may change when you
  perform a new run due to changes in IP address, user account, port number,
  SSH key file path, proxy settings, or other options.<br /><br />`ssh -p 22
      root@34.127.82.9`
</Note>

## Tips & tricks

Keep in mind that GPUs are fully dedicated to a notebook server --and therefore consume credits-- even when you are not running compute-intensive cells. To optimize GPU usage, use tools like [nbconvert](https://nbconvert.readthedocs.io/en/latest/usage.html#executable-script) to convert the notebook into a Python file or package it as a Python container and run it as a batch job.

You can also mount volumes to interactive workloads by defining `import` and reference files or datasets from your notebook.

## Using our web interface

You can repeat the same process on the web. Head over to your **Organization**, select a project, and create a **New run**.

<div style={{ position: 'relative', paddingBottom: 'calc(66.6667% + 41px)', height: '0px' }}>
  <iframe src="https://demo.arcade.software/cmpPGwYc2KCy9rhIbVzV?embed" frameBorder="0" loading="lazy" webkitAllowFullScreen="" mozAllowFullScreen="" title="Dashboards" style={{ position: 'absolute', top: '0px', left: '0px', width: '100%', height: '100%', colorScheme: 'light' }} />
</div>

## What's next?

Next, let's see how you use our interactive workloads to host a web app on the cloud using tools like Streamlit and Gradio.

<CardGroup cols={3}>
  <Card title="Image Generation Playground" icon="image" href="image generation">
    Launch an interactive web application for image generation
  </Card>

  <Card title="Phi-4 fine-tuning" icon="wrench" href="phi-4-finetuning">
    Fine-tune Phi-4 with counselling datasets
  </Card>

  <Card title="Phi-4-mini Deployment" icon="server" href="phi-4-deployment">
    Serve & deploy vLLM-accelerated Phi-4-mini-reasoning
  </Card>
</CardGroup>
