---
title: "Use Dynamic Resource Allocation for GPUs"
description: "Step-by-step guide to exposing GPUs on SKS nodes with the NVIDIA DRA driver and allocating them to pods with ResourceClaims"
url: https://community.exoscale.com/product/compute/containers/how-to/gpu-dra/
product: "Containers (SKS)"
section: product
last_updated: 2026-11-24
---
> For AI agents: the documentation index is at https://community.exoscale.com/llms.txt. Every page is available as markdown at `<page URL>index.md` or with `Accept: text/markdown`.

# Use Dynamic Resource Allocation for GPUs

SKS nodes can expose their GPUs with the [NVIDIA DRA driver for GPUs](https://github.com/kubernetes-sigs/dra-driver-nvidia-gpu) instead of the [NVIDIA device plugin](https://community.exoscale.com/product/compute/containers/how-to/gpu-sks-nodes/index.md). With [Dynamic Resource Allocation (DRA)](https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/), the driver publishes the GPUs, or their MIG instances, in `ResourceSlices`, and workloads request them with `ResourceClaims` or `ResourceClaimTemplates` that reference one of these DeviceClasses:

- `gpu.nvidia.com`: a full GPU.
- `mig.nvidia.com`: a MIG instance (see [Use GPU MIG Partitioning](https://community.exoscale.com/product/compute/containers/how-to/gpu-mig-partitioning/index.md)).

With DRA, nodes no longer advertise the `nvidia.com/gpu` resource, and a pod only gets the GPUs allocated to its claims.

## Prerequisites

- An SKS cluster running Kubernetes 1.34 or greater (`resource.k8s.io/v1` API).
- A GPU instance type for the nodepool.

## Install the DeviceClasses

SKS does not install the DeviceClasses. Apply them once per cluster:

```bash
cat <<EOF | kubectl apply -f -
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata:
  name: gpu.nvidia.com
spec:
  selectors:
  - cel:
      expression: "device.driver == 'gpu.nvidia.com' && device.attributes['gpu.nvidia.com'].type == 'gpu'"
---
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata:
  name: mig.nvidia.com
spec:
  selectors:
  - cel:
      expression: "device.driver == 'gpu.nvidia.com' && device.attributes['gpu.nvidia.com'].type == 'mig'"
EOF
```

## Enable DRA on SKS Standard NodePools

> [!WARNING]
> Enabling or disabling the DRA driver on an existing nodepool only affects newly provisioned nodes. To make current nodes pick up the change, you have to [cycle your nodes](https://community.exoscale.com/product/compute/containers/how-to/lifecycle-management/index.md#drain-and-destroy-nodes-one-by-one).

### CLI

Create a cluster with a default nodepool using the DRA driver:

```sh
exo compute sks create my-cluster \
  --zone ch-gva-2 \
  --nodepool-name gpu-pool \
  --nodepool-size 1 \
  --nodepool-instance-type gpua30.large \
  --nodepool-nvidia-dra-driver
```

Add a nodepool using the DRA driver to an existing cluster:

```sh
exo compute sks nodepool add my-cluster gpu-pool \
  --instance-type gpua30.large \
  --size 1 \
  --nvidia-dra-driver
```

Enable the DRA driver on an existing nodepool, or pass `--nvidia-dra-driver=false` to switch back to the device plugin:

```sh
exo compute sks nodepool update my-cluster gpu-pool --nvidia-dra-driver
```

To expose MIG instances, also set a MIG profile with `--nvidia-mig-profile` (or `--nodepool-nvidia-mig-profile`): each MIG instance is then published as a `mig.nvidia.com` device.

### Terraform Provider

Set the `nvidia_dra_driver` attribute of the `exoscale_sks_nodepool` resource, optionally with `nvidia_mig_profile`:

```hcl
resource "exoscale_sks_nodepool" "gpu" {
  zone       = "ch-gva-2"
  cluster_id = exoscale_sks_cluster.my_cluster.id
  name       = "gpu-pool"

  instance_type      = "gpua30.large"
  size               = 1
  nvidia_dra_driver  = true
  nvidia_mig_profile = "1g.6gb" # optional
}
```

## Enable DRA on Karpenter Nodepools

In `spec.userData` of the Karpenter `ExoscaleNodeClass`, disable the NVIDIA device plugin and enable the NVIDIA DRA driver. If the device plugin stays enabled, it is used instead of the DRA driver. To expose MIG instances, add the MIG settings described in [Use GPU MIG Partitioning](https://community.exoscale.com/product/compute/containers/how-to/gpu-mig-partitioning/index.md#enable-mig-on-karpenter-nodepools).

```yaml
apiVersion: karpenter.exoscale.com/v1
kind: ExoscaleNodeClass
metadata:
  name: nvidia-dra
spec:
  imageTemplateSelector:
    variant: nvidia
  diskSize: 100                                # Beware that GPU nodes enforce minimum disk size

  securityGroupSelectorTerms:
  - id: "5ea00f6e-1e92-456b-9381-2cb2c5937240" # Don't forget to attach proper security group

  userData: |
    [settings.kubelet-device-plugins.nvidia]
    enabled = false

    [settings.kubelet-dra-drivers.nvidia]
    enabled = true
```

> [!IMPORTANT]
> Karpenter does not yet provision nodes for pods with `ResourceClaims`, see [Limitations](#limitations).

## Running and Testing GPU Jobs

Once nodes are ready, check that their GPUs are published:

```bash
kubectl get resourceslices
```

Create a `ResourceClaimTemplate` requesting one full GPU, and a pod using it. On nodepools with a MIG profile, use the `mig.nvidia.com` DeviceClass instead.

```bash
cat <<EOF | kubectl apply -f -
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
  name: single-gpu
spec:
  spec:
    devices:
      requests:
      - name: gpu
        exactly:
          deviceClassName: gpu.nvidia.com
---
apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  restartPolicy: Never
  resourceClaims:
  - name: gpu
    resourceClaimTemplateName: single-gpu
  containers:
    - name: cuda-container
      image: nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda11.7.1-ubuntu20.04
      resources:
        claims:
        - name: gpu
  tolerations:
  - key: nvidia.com/gpu
    operator: Exists
    effect: NoSchedule
EOF
```

Check that the claim is allocated and that the pod ran on the GPU:

```bash
kubectl get resourceclaims
kubectl logs gpu-pod
```

## Limitations

Karpenter does not yet provision nodes for pods with `ResourceClaims`: such pods stay pending until a node with a matching device exists, for example in an SKS Standard nodepool.

