Skip to content

About

Install the NVIDIA GPU Operator and HAMi on a GreenNode VKS cluster with one command, and verify GPU sharing with hard VRAM limits. Verified on a VKS node with a GeForce RTX 2080 Ti.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GPU sharing on Kubernetes with HAMi — GreenNode VKS sample

Install the NVIDIA GPU Operator and HAMi with one command, then prove that two pods can share one GPU with a hard VRAM limit each. Verified on a GreenNode VKS GPU node (see Tested on).

CI License: MIT

Why this exists

A VKS node group with GPU nodes comes with no NVIDIA driver and no device plugin, and nvidia.com/gpu does not appear until a device plugin runs. This sample installs:

Component Role
GPU Operator NVIDIA driver, container toolkit, node labels. Its own device plugin is off
HAMi The only device plugin + scheduler. Splits one GPU's memory and cores between pods

Only one device plugin may run. Two plugins that both register nvidia.com/gpu let pods get a GPU with no VRAM limit.

Quick start

Requirements: kubectl pointing at your VKS cluster, helm 3, and nodes with Internet access (they pull images from nvcr.io, docker.io and registry.k8s.io).

git clone https://github.com/GreenNode-Samples/sample-vks-gpu-hami && cd sample-vks-gpu-hami
./install.sh      # GPU Operator, waits for the driver, then HAMi
./verify.sh       # PASS/FAIL checks + a two-pod VRAM isolation test

Expected output of ./verify.sh:

PASS  no image pull errors
PASS  GPU Operator ClusterPolicy ready
PASS  only one device plugin (HAMi)
PASS  HAMi scheduler and device plugin running
PASS  virtual GPUs advertised: <cards x 10>
PASS  pod A sees 2000 MiB
PASS  pod B sees 3000 MiB

The driver is compiled on the node, so the first install takes several minutes (4.5 minutes in our test). install.sh finds GPU nodes by themselves (Node Feature Discovery label for NVIDIA PCI devices). To choose them yourself: GPU_NODES="node-a node-b" ./install.sh.

Use it in your workloads

Schedule with HAMi and ask for a slice of the GPU:

spec:
  schedulerName: hami-scheduler
  containers:
  - name: app
    resources:
      limits:
        nvidia.com/gpu: 1          # one virtual GPU
        nvidia.com/gpumem: 4000    # MiB of VRAM (must not exceed one physical card)
        nvidia.com/gpucores: 30    # % of compute

nvidia.com/gpu: 20 on a node means 20 virtual GPUs (HAMi splits each card into 10 by default), not 20 cards.

Tested on

Date 2026-12-02
Platform GreenNode VKS, Kubernetes v1.32.9, zone HCM03-1A, node image Ubuntu 22.04 (kernel 5.15.0-179)
GPU 1× GeForce RTX 2080 Ti, 11 GB (consumer card), installed with CONSUMER_GPU=1
Versions GPU Operator v26.3.3 (driver 580.126.20, the chart default), HAMi 2.9.0
Result ./verify.sh: all 7 checks PASS; the node advertised 10 virtual GPUs; two pods asking 2000 MiB and 3000 MiB saw exactly that

Not covered by this test: datacenter cards (the default install without CONSUMER_GPU) and multi-GPU or multi-node clusters.

Scale and new nodes

New GPU nodes are not labeled automatically. Label them so the HAMi device plugin runs there: kubectl label node <node> gpu=true. (Re-running ./install.sh does it for every detected GPU node.)

Versions and keeping up with changes

  • Chart versions are pinned in versions.env (GPU_OPERATOR_VERSION, HAMI_VERSION) — the combination we tested. Upgrade by changing one line, then run ./install.sh and ./verify.sh.
  • The HAMi kube-scheduler image tag is set to your cluster's Kubernetes version automatically.
  • CI (every push and weekly) runs static checks only: shellcheck, helm lint/helm template of both pinned charts, a check that every key in values/*.yaml exists in the chart defaults (Helm silently ignores unknown keys), assertions on the rendered manifests (upstream kube-scheduler image, no mirror registry, device plugin off in the operator), helm install --dry-run=server on a kind cluster, and install.sh up to node selection with a fake NFD label. CI has no GPU, so driver build, HAMi scheduling and verify.sh are not exercised there: run them on your own GPU cluster.
  • No GreenNode IDs, flavors or endpoints are used anywhere.

What is enabled (and what is not)

Only what HAMi needs is switched on, so nothing competes with it:

Component State
GPU Operator: driver, container toolkit, CDI, node feature discovery on
GPU Operator: device plugin, GPU feature discovery, MIG manager, DCGM exporter, vGPU/VFIO/Kata/sandbox and confidential-computing components off
HAMi: scheduler, device plugin on
HAMi: handlers for non-NVIDIA devices (Kunlun, Enflame, Moore Threads, VastAI) off

CI fails if any other GPU Operator component becomes enabled.

Uninstall

./uninstall.sh    # removes HAMi first, then the GPU Operator (order matters)

Notes and pitfalls

  • Remove HAMi before touching the driver. HAMi keeps the GPU's NVML open, so the driver cannot be unloaded or upgraded while HAMi runs. driver.upgradePolicy.autoUpgrade is false in values/gpu-operator.yaml for this reason.
  • Consumer GPUs (GeForce, e.g. RTX 2080 Ti): the default open kernel module requires the GSP firmware, and on some consumer cards the firmware fails to start (nvidia-smi shows "No devices were found"). Datacenter cards (A100, L40S, H100) are expected to work with the defaults (this repository's test did not cover them). For GeForce cards run CONSUMER_GPU=1 ./install.sh: it uses the proprietary kernel module (values/consumer-gpu.yaml) and switches the GSP firmware off (manifests/kernel-module-params-cm.yaml). If nvidia-smi then hangs for about two minutes and fails with RmInitAdapter failed (0x25:0x65), the card needs a PCI function-level reset (FLR) from inside the node; that step is manual and not scripted here.
  • Pods requesting more gpumem than one card has stay Pending forever.
  • No egress on the nodes? The default path needs Internet from the nodes. For air-gapped clusters, mirror the images to a private registry (vCR) and override the image repositories in the values files.

Layout

File Purpose
install.sh / verify.sh / uninstall.sh Install, check, remove
lib.sh Shared helper (cluster version parsing)
versions.env Pinned chart and image versions
values/gpu-operator.yaml, values/hami.yaml Helm values with the required settings
ci/ Scripts used by CI (values key check, rendered-manifest checks, unit test)
.github/workflows/ci.yml Static checks on push and weekly

License

MIT — see LICENSE.

About

Install the NVIDIA GPU Operator and HAMi on a GreenNode VKS cluster with one command, and verify GPU sharing with hard VRAM limits. Verified on a VKS node with a GeForce RTX 2080 Ti.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages