Skip to content

About

Device-plugin for volcano vgpu which support hard resource isolation

Resources

Code of conduct

Contributing

Security policy

Stars

180 stars

Watchers

3 watching

Forks

Volcano vGPU device plugin

OpenSSF Best Practices

A Kubernetes device plugin that lets pods share NVIDIA GPUs under the Volcano scheduler. It is a subproject of HAMi, based on the NVIDIA device plugin, and uses HAMi-core to enforce per-container memory and core limits.

A GPU is split into several vGPUs. Each pod asks for a number of vGPUs and, optionally, device memory and a share of the cores. There are two sharing modes:

  • hami-core: software isolation, works on any GPU.
  • mig: dynamic MIG, hardware isolation, needs a MIG-capable GPU such as A30, A100 or H100, see NVIDIA's supported GPU list.

A node uses one mode, and a cluster can mix both. Plugin settings are described in doc/config.md.

Compatibility

volcano-vgpu Volcano
v1.13.0 v1.15.1 and above
v1.12.0 and below v1.15.0 and below
master master

The plugin is built with client-go 0.37. The manifests in this repository were validated against Kubernetes 1.37 and Volcano v1.16.0.

Requirements

  • An NVIDIA driver and the NVIDIA Container Toolkit on every GPU node, with nvidia as the default container runtime.
  • The Volcano scheduler with vGPU enabled (below).

Enable vGPU in Volcano

In volcano-scheduler-configmap (namespace volcano-system), add the deviceshare plugin with VGPUEnable. This is the Volcano v1.16 default configuration with deviceshare added:

actions: "enqueue, allocate, backfill"
tiers:
- plugins:
  - name: priority
  - name: gang
    enablePreemptable: false
  - name: conformance
- plugins:
  - name: overcommit
  - name: drf
    enablePreemptable: false
  - name: deviceshare
    arguments:
      deviceshare.VGPUEnable: true
      deviceshare.SchedulePolicy: binpack  # or spread
  - name: predicates
  - name: proportion
  - name: nodeorder
  - name: binpack

Then restart volcano-scheduler and touch the node annotations. deviceshare registers vGPU support only once per process, so a hot reload alone can leave it disabled, and the annotation update makes the scheduler read each node's volcano.sh/node-vgpu-register again. Other Volcano components do not need a restart:

kubectl rollout restart deployment/volcano-scheduler -n volcano-system
kubectl rollout status deployment/volcano-scheduler -n volcano-system
kubectl annotate nodes --all volcano.sh/vgpu-resync="$(date +%s)" --overwrite

Install

Install chart version 1.13.0 from the Helm repository:

helm repo add volcano-vgpu https://project-hami.github.io/volcano-vgpu-device-plugin
helm repo update
helm install volcano-vgpu-device-plugin volcano-vgpu/volcano-vgpu-device-plugin --version 1.13.0

The same chart is also available through GHCR OCI:

helm install volcano-vgpu-device-plugin \
  oci://ghcr.io/project-hami/charts/volcano-vgpu-device-plugin --version 1.13.0

Or apply the plain manifest:

kubectl apply -f deployments/static/volcano-vgpu-device-plugin.yml

Useful chart options:

  • --set cdi.enabled=true passes devices through CDI instead of environment variables.
  • --set nvmlMock.enabled=true runs against nvml-mock on a cluster without GPUs, which is enough to check scheduling and registration. It cannot be combined with cdi.enabled.

Check that the node reports vGPUs:

kubectl get node <node> -o jsonpath='{.status.allocatable}'

volcano.sh/vgpu-number and volcano.sh/vgpu-memory should be listed. The number capacity is the GPU count times deviceSplitCount (10 by default). The memory capacity is expressed in the blocks described below, not always in MiB.

With Karpenter, GPU nodes start from zero only if Karpenter knows these resources in advance: see doc/karpenter.md.

After creating a vGPU pod, verify that Volcano added the device allocation annotations:

kubectl get pod <pod> -o yaml | grep -E \
  'volcano.sh/(devices-to-allocate|vgpu-ids-new|vgpu-node)'

If a pod that has not yet been allocated was created before the updated configuration took effect and lacks these annotations, kubelet may reject it with UnexpectedAdmissionError: Allocate failed due to rpc error: code = Unknown desc = cannot get valid pod; recreate it after the volcano-scheduler restart and node annotation step.

Run a vGPU job

Request vGPUs in resources.limits:

apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
  annotations:
    volcano.sh/vgpu-mode: "hami-core"  # optional: hami-core or mig
spec:
  schedulerName: volcano
  containers:
  - name: cuda
    image: nvidia/cuda:13.5.0-base-ubuntu24.04
    command: ["sleep", "infinity"]
    resources:
      limits:
        volcano.sh/vgpu-number: 1    # one vGPU
        volcano.sh/vgpu-memory: 3000 # optional: memory blocks per vGPU
        volcano.sh/vgpu-cores: 50    # optional: percent of a GPU per vGPU

Each vGPU of a container lands on a different GPU, so a container cannot request more vGPUs than the node has GPUs. Without the volcano.sh/vgpu-mode annotation, either mode may be used. The image needs a node driver that supports its CUDA version; pick an older tag for older drivers.

GPU memory units

volcano.sh/vgpu-memory is an integer count of memory blocks. Each block is gpuMemoryFactor MiB, configured through deviceConfig.nvidia.gpuMemoryFactor in the Helm chart. The default factor is 1, so the request value equals MiB only with the default configuration.

In hami-core mode, each requested vGPU receives:

memory limit per vGPU (MiB) = vgpu-memory request * gpuMemoryFactor
vgpu-memory request = ceil(desired memory in MiB / gpuMemoryFactor)

For example, with gpuMemoryFactor: 2, a request of 1500 gives each requested vGPU a 3000 MiB limit in hami-core mode. When the desired limit is not an exact multiple of the factor, round the request up to a whole block. In mig mode, the plugin skips the calculated CUDA memory limit and the assigned MIG geometry determines the available memory (which may exceed the requested size).

The plugin registers one synthetic device for every memory block. For each GPU, the registered block count is floor(GPU memory in MiB / gpuMemoryFactor). Keep the sum across a node at or below 60000; a larger ListAndWatch response can exceed kubelet's default gRPC receive limit and leave volcano.sh/vgpu-memory at zero. Use the smallest factor that keeps the largest node in the cluster below this limit.

Use the same factor for every node that exposes the same memory resource name. Otherwise, the same Pod request represents different memory limits depending on the selected node. Changing the factor also changes the meaning of existing Pod manifests; update their vgpu-memory values before deploying the new configuration. Recreate running vGPU Pods after the change so they are allocated with the new block size.

In hami-core mode nvidia-smi inside the container shows the resulting memory limit. In mig mode it shows the memory of the assigned MIG instance, which comes from the configured MIG geometry.

Metrics

The monitor container of the plugin pod serves per-container GPU usage and limits on port 9394. It is not deployed with monitor.enabled=false or nvmlMock.enabled=true:

curl <plugin-pod-ip>:9394/metrics

Release notes

See CHANGELOG.md for summaries of the release tags and links to the published GitHub release notes.

Contributing and security

See CONTRIBUTING.md. Report vulnerabilities as described in SECURITY.md, not in a public issue. Questions go to GitHub issues or the HAMi community.

License

Apache-2.0, see LICENSE.

About

Device-plugin for volcano vgpu which support hard resource isolation

Resources

Code of conduct

Contributing

Security policy

Stars

180 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages