Skip to content

Request NPUs with DRA

Request one NPU through a Dynamic Resource Allocation (DRA) ResourceClaimTemplate and verify the allocated device inside a Pod. To specify a count, product name, PCIe topology, or UUID, see Specify NPU allocation conditions with DRA.

Use the DRA configuration. If the Operator is not installed, follow Installing the NPU Operator.

1. Create the claim template and Pod

Create the npu-tutorial namespace, a ResourceClaimTemplate, and a Pod.

Use npu as the name in both resources.claims and resourceClaims to link the container to its claim.

kubectl create namespace npu-tutorial --dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f - <<'EOF'
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
  name: npu-request
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 1
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-npu
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: npu-request
EOF

2. Verify the device

Wait for the Pod, then check the claim allocation and the device inside the container.

Pod readiness
$ kubectl wait -n npu-tutorial --for=condition=Ready pod/dra-npu --timeout=180s
pod/dra-npu condition met
1
2
3
4
CLAIM=$(kubectl get pod -n npu-tutorial dra-npu -o jsonpath='{.status.resourceClaimStatuses[0].resourceClaimName}')
kubectl get resourceclaim -n npu-tutorial "$CLAIM" \
  -o json | \
  jq '.status.allocation.devices.results | map({driver, pool, device})'
Claim allocation
[
  {
    "driver": "npu.rebellions.ai",
    "pool": "node-rebel100",
    "device": "rbln0"
  }
]
NPU inside the container
$ kubectl exec -n npu-tutorial dra-npu -- rbln-smi -L
NPU 0 : RBLN-CR13 (UUID: NPU-34428712-d887-840b-a7b9-1c9e05807fc3)
Claim allocation
[
  {
    "driver": "npu.rebellions.ai",
    "pool": "node-atom",
    "device": "rbln0"
  }
]
NPU inside the container
$ kubectl exec -n npu-tutorial dra-npu -- rbln-smi -L
NPU 0 : RBLN-CA25 (UUID: NPU-c5ba8327-5b18-847e-953e-4ca4b4daeb44)

The check passes when the claim has an allocation and the container lists one NPU.

Clean up

Delete the Pod and ResourceClaimTemplate. The claim generated for the Pod is deleted automatically.

kubectl delete pod -n npu-tutorial dra-npu
kubectl delete resourceclaimtemplate -n npu-tutorial npu-request