> For the complete documentation index, see [llms.txt](https://docs.zerve.ai/zerve-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zerve.ai/zerve-docs/compute/gpus.md).

# GPUs

Run blocks on GPUs, and what to do when GPUs are in short supply.

For model training, deep learning and other GPU work, run a block on **GPU** compute (AWS SageMaker).

## GPU settings

| Setting                          | What it does                                                                                                    |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| **Instance type**                | The GPU instance to run on                                                                                      |
| **Spot instances**               | Use spare capacity at a lower cost. Spot instances can be interrupted, so they suit work that can be restarted. |
| **Keep-alive**                   | Keep the instance running between block runs, so the next run starts faster                                     |
| **Maximum run time**             | The longest the block can run                                                                                   |
| **Maximum wait time**            | The longest to wait for an instance to become available                                                         |
| **Retry until GPU is available** | How long to keep trying when no GPU is available. See below.                                                    |

## GPU instance types

| Family   | Instance types                                                                                                                            |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **G5**   | `ml.g5.xlarge`, `ml.g5.2xlarge`, `ml.g5.4xlarge`, `ml.g5.8xlarge`, `ml.g5.12xlarge`, `ml.g5.16xlarge`, `ml.g5.24xlarge`, `ml.g5.48xlarge` |
| **G4dn** | `ml.g4dn.xlarge`, `ml.g4dn.2xlarge`, `ml.g4dn.4xlarge`                                                                                    |
| **P3**   | `ml.p3.2xlarge`                                                                                                                           |
| **P2**   | `ml.p2.xlarge`                                                                                                                            |

The compute settings show each instance's GPU model, CPU, memory and GPU memory.

## When GPUs are in short supply

GPU capacity in the cloud isn't guaranteed. At busy times, the instance type you've chosen may not be available.

**Retry until GPU is available** controls what happens then:

| Option                  | What happens                                       |
| ----------------------- | -------------------------------------------------- |
| **Never** (the default) | The run fails straight away if no GPU is available |
| **15 minutes**          | Zerve keeps trying for up to 15 minutes            |
| **1 hour**              | Zerve keeps trying for up to an hour               |
| **12 hours**            | Zerve keeps trying for up to 12 hours              |

While retrying, Zerve waits a little longer between each attempt.

If a run fails because no GPU was available, you can turn on retries, choose a different instance type, or try again later.

{% hint style="info" %}
For overnight or scheduled training jobs, set a longer retry window, so a temporary shortage doesn't stop the job.
{% endhint %}

## Use a GPU environment

A GPU only helps if the block's environment includes GPU-enabled libraries. Use the **Deep Learning (CUDA 12.6)** preset, which includes PyTorch and TensorFlow for GPUs, or add GPU versions of your libraries to your own environment. See [Environment presets](/zerve-docs/environments/environment-presets.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zerve.ai/zerve-docs/compute/gpus.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
