Skip to content

Specify NPU allocation conditions with DRA

Select NPUs with a DRA request count, CEL selectors, or PCIe topology constraints. For the basic request and verification workflow, see Request NPUs with DRA.

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

1. Inspect device attributes

Product names, PCIe roots, and UUIDs vary by node. Check the actual device attributes and values first. See NPU Properties for attribute descriptions.

kubectl get resourceslices
kubectl describe resourceslice <NAME>

2. Specify request conditions

Run the example you need.

Request two NPUs

Set exactly.count to 2. At least two NPUs must be available for allocation on the same node.

export DRA_POD=dra-two-npus
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: dra-two-npus
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 2
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-two-npus
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: dra-two-npus
EOF

Select an NPU by product name

Specify a product name under exactly.selectors to request one NPU.

export DRA_POD=dra-rebel100
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: dra-rebel100
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 1
          selectors:
          - cel:
              expression: device.attributes["npu.rebellions.ai"].productName == "RBLN-CR13"
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-rebel100
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: dra-rebel100
EOF
export DRA_POD=dra-atom
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: dra-atom
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 1
          selectors:
          - cel:
              expression: device.attributes["npu.rebellions.ai"].productName == "RBLN-CA25"
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-atom
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: dra-atom
EOF

Request NPUs on the same PCIe root

Set matchAttribute under devices.constraints to request two NPUs attached to the same PCIe root complex.

The RBLN-CA25 contains four NPU chips per card. A root complex can serve multiple cards, so this constraint does not guarantee that the NPUs are on the same card.

export DRA_POD=dra-pcie-root
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: dra-pcie-root
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 2
      constraints:
      - requests: ["npu"]
        matchAttribute: resource.kubernetes.io/pcieRoot
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-pcie-root
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: dra-pcie-root
EOF

Select an NPU by UUID

Use the uuid attribute to request a specific NPU. Replace the example UUID with the actual value from a ResourceSlice. If you copy the UUID from rbln-smi -L, omit the NPU- prefix.

export DRA_POD=dra-uuid
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: dra-uuid
  namespace: npu-tutorial
spec:
  spec:
    devices:
      requests:
      - name: npu
        exactly:
          deviceClassName: npu.rebellions.ai
          count: 1
          selectors:
          - cel:
              expression: device.attributes["npu.rebellions.ai"].uuid == "34428712-d887-840b-a7b9-1c9e05807fc3"
---
apiVersion: v1
kind: Pod
metadata:
  name: dra-uuid
  namespace: npu-tutorial
spec:
  containers:
  - name: ubuntu
    image: ubuntu:22.04
    command: ["sleep", "infinity"]
    resources:
      claims:
      - name: npu
  resourceClaims:
  - name: npu
    resourceClaimTemplateName: dra-uuid
EOF

3. Verify the allocation

Wait for the selected example's Pod ($DRA_POD) to become Ready.

kubectl wait -n npu-tutorial --for=condition=Ready "pod/$DRA_POD" --timeout=180s

Inspect the claim allocation and the NPUs inside the container.

1
2
3
4
5
CLAIM=$(kubectl get pod -n npu-tutorial "$DRA_POD" -o jsonpath='{.status.resourceClaimStatuses[0].resourceClaimName}')
kubectl get resourceclaim -n npu-tutorial "$CLAIM" \
  -o json | \
  jq '.status.allocation.devices.results | map({driver, pool, device})'
kubectl exec -n npu-tutorial "$DRA_POD" -- rbln-smi -L

Check the result for the selected example.

Example Expected result
Request two NPUs Both the claim allocation and rbln-smi -L list two devices
Select a product name One NPU is allocated, and its product name in rbln-smi -L matches the requested value
Same PCIe root Two NPUs are allocated, and their resource.kubernetes.io/pcieRoot values in the ResourceSlice match
Select a UUID One NPU is allocated, and its UUID in rbln-smi -L, without the NPU- prefix, matches the requested UUID

Clean up

Delete the selected example's Pod and ResourceClaimTemplate. The generated claim is deleted automatically. Release the NPUs before running another example.

kubectl delete pod -n npu-tutorial "$DRA_POD"
kubectl delete resourceclaimtemplate -n npu-tutorial "$DRA_POD"