Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/contributor/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ sidebar_label: Roadmap
- [ ] Rich observability support
- [x] DRA support
- [ ] Support Intel GPU device
- [ ] Support AMD GPU device
- [x] Support AMD GPU device
- [x] Support Enflame GCU device
196 changes: 196 additions & 0 deletions docs/userguide/amd-device/enable-amd-gpu-sharing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
title: Enable AMD GPU Sharing
sidebar_label: GPU Sharing
---

## Introduction

HAMi supports sharing AMD Instinct/ROCm GPUs. Workloads request device memory and compute-unit (CU) share through standard Kubernetes resources, without application code changes.

**GPU sharing**: Multiple tasks can share one AMD GPU instead of occupying a whole card.

**Device memory control**: Allocate a specific amount of device memory (MiB). HAMi enforces a hard limit so usage cannot exceed the allocation.

**Device compute core limitation**: Allocate a percentage of compute units (`amd.com/gpucores: 25` means about 25% of the device CUs).

:::caution

Use the [amd-device-plugin](https://github.com/Project-HAMi/amd-device-plugin) image and Helm chart. Do not deploy the upstream ROCm `k8s-device-plugin` image for HAMi soft vGPU.

Fractional memory isolation loads `libamvgpu.so` through glibc `LD_AUDIT` and currently requires glibc symbols through `GLIBC_2.34`. Workload images based on older glibc (for example Ubuntu 20.04 or RHEL 8) or musl/Alpine are not supported yet. See [HAMi#2265](https://github.com/Project-HAMi/HAMi/issues/2265).

:::

## Prerequisites

Deploy these components:

| Component | Role | Key requirement |
| --- | --- | --- |
| HAMi | Scheduling, allocation, and admission | Scheduler is running and manages the three AMD resources |
| AMD GPU Operator (recommended) | Driver and ROCm environment | Disable the Operator native device-plugin |
| [amd-device-plugin](https://github.com/Project-HAMi/amd-device-plugin) | Register AMD resources, allocate CUs, inject runtime limits | Deploy chart/image `0.0.1` or newer; discovers VRAM/CU via amd-smi/libdrm |

Nodes also need a working AMD driver and ROCm (validated with ROCm 7.0.2). Verify with:

```bash
amd-smi static --gpu 0
```

The output should include the device model, VRAM, and `NUM_COMPUTE_UNITS`.

## Enabling AMD GPU Sharing

### Configure HAMi

After installing HAMi, confirm the scheduler manages all AMD vGPU resources. The values file should include:

```yaml
devices:
amd:
customresources:
- amd.com/gpu
- amd.com/gpumem
- amd.com/gpucores
```

Confirm the scheduler is running:

```bash
kubectl -n kube-system get pods | grep hami-scheduler
```

### Disable the AMD GPU Operator device-plugin

If you use the [AMD GPU Operator](https://github.com/ROCm/gpu-operator) for drivers and ROCm, disable its native device-plugin so it does not compete with HAMi `amd-device-plugin` for `amd.com/gpu`:

```bash
kubectl -n kube-amd-gpu patch deviceconfig default --type=merge -p \
'{"spec":{"devicePlugin":{"enableDevicePlugin":false}}}'
```

`amd-device-plugin` reads per-device VRAM, CU count, UUID, and product name through amd-smi/libdrm, so the Operator node-labeller is optional for HAMi soft vGPU.

### Deploy amd-device-plugin

Deploy [amd-device-plugin](https://github.com/Project-HAMi/amd-device-plugin) to all AMD GPU nodes. Chart `0.0.1` defaults to image `ghcr.io/project-hami/amd-device-plugin:0.0.1` and installs the bundled `libamvgpu.so` hook onto the node through a `postStart` lifecycle hook:

```bash
helm upgrade --install amd-gpu \
https://github.com/Project-HAMi/amd-device-plugin/releases/download/amd-gpu-helm-0.0.1/amd-gpu-0.0.1.tgz \
--namespace kube-system \
--create-namespace
```
Comment thread
FouoF marked this conversation as resolved.
Comment on lines +76 to +83

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Project-HAMi amd-device-plugin helm values node_selector_enabled values.yaml

💡 Result:

The node_selector_enabled parameter and related node_selector settings are features of the official ROCm k8s-device-plugin Helm chart [1][2], not the Project-HAMi Helm chart [3][4]. Project-HAMi does not use the node_selector_enabled flag in its values.yaml [3][4]. Instead, HAMi manages device plugin deployment and node configuration through its own parameters, such as devicePlugin.nvidiaNodeSelector (which defaults to {"gpu": "on"}) [4] and per-node configurations managed via ConfigMaps [5]. If you are using the ROCm k8s-device-plugin Helm chart (found on Artifact Hub [1]), the node_selector_enabled value in values.yaml functions as follows: 1. Purpose: When set to true, it enables the use of node_selector in the DaemonSet specification [2][6]. 2. Default: It defaults to false [1][2]. 3. Configuration: When node_selector_enabled is true, the chart uses the labels defined under node_selector in values.yaml [1][2]. A common default selector used by this chart is feature.node.kubernetes.io/pci-0300_1002.present: "true" [1][2]. If you are attempting to configure node selection in Project-HAMi, you should refer to the devicePlugin.nvidiaNodeSelector field in the HAMi Helm chart values.yaml or define per-node overrides in the hami-device-plugin ConfigMap [3][4][5].

Citations:


🌐 Web query:

raw.githubusercontent.com/Project-HAMi/amd-device-plugin/amd-gpu-helm-0.0.1/helm/amd-gpu/values.yaml

💡 Result:

The URL provided, raw.githubusercontent.com/Project-HAMi/amd-device-plugin/amd-gpu-helm-0.0.1/helm/amd-gpu/values.yaml, refers to a location that does not correspond to an official or maintained component of the Project-HAMi repository [1]. Project-HAMi is a middleware project designed to facilitate the virtualization and sharing of heterogeneous AI accelerators (such as GPUs, NPUs, and DCUs) across Kubernetes workloads [1]. While the project actively supports multiple hardware vendors, the official device management, scheduling, and configuration for all supported accelerators, including AMD, are centralized within the main Project-HAMi Helm chart (located in the charts/hami directory of the Project-HAMi/HAMi repository) [2][3][1]. Key distinctions to note: - AMD device support: Project-HAMi has been actively developing support for AMD Instinct GPUs, including features for GPU memory limiting and computing unit (CU) partitioning [4][5]. This implementation is integrated directly into the core HAMi project infrastructure [1]. - Independent Plugins: Native AMD device plugins (such as the one found at github.com/ROCm/k8s-device-plugin) are designed for the native Kubernetes scheduler and are not directly compatible with the HAMi scheduler, which requires specific protocols for device annotation and vGPU allocation [6][1]. - Configuration: All configuration for HAMi, including device-specific settings, is managed through the central HAMi Helm chart values.yaml and associated ConfigMaps [7][1]. If you are looking to configure AMD support within HAMi, you should refer to the official documentation and the main values.yaml file found in the Project-HAMi/HAMi repository [7][1].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Fetch and inspect only the chart values/template metadata needed for DaemonSet scheduling,
# without running any repository code.
url="https://raw.githubusercontent.com/Project-HAMi/amd-device-plugin/amd-gpu-helm-0.0.1/helm/amd-gpu/values.yaml"
template_url="https://raw.githubusercontent.com/Project-HAMi/amd-device-plugin/amd-gpu-helm-0.0.1/helm/amd-gpu/templates/daemonset.yaml"

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

wget -qO- "$url" 2>/dev/null > "$tmpdir/values.yaml" || curl -sSL "$url" > "$tmpdir/values.yaml"
wget -qO- "$template_url" 2>/dev/null > "$tmpdir/daemonset.yaml" || curl -sSL "$template_url" > "$tmpdir/daemonset.yaml"

python3 - <<'PY' "$tmpdir/values.yaml" "$tmpdir/daemonset.yaml"
import sys
from pathlib import Path
for p in sys.argv[1:]:
    print(f"\n--- {Path(p).name}:")
    data = Path(p).read_text()
    for needle in ["node_selector_enabled", "nodeSelector", "nodeAffinity", "podAffinity", "privileged", "postStart"]:
        idx = data.find(needle)
        if idx >= 0:
            start = max(0, idx-120)
            end = min(len(data), idx+220)
            print(f"\n[context] {needle}:")
            print(data[start:end].replace("\n", "\n"))

data = Path(sys.argv[1]).read_text()
print("\n--- relevant selectors/config in values.yaml ---")
for line in data.splitlines():
    if any(s in line for s in ["node_selector_enabled", "nodeSelector", "nodeAffinity", "postStart"]):
        print(line)
PY

Repository: Project-HAMi/website

Length of output: 1336


Scope the AMD device-plugin DaemonSet to AMD nodes.

values.yaml sets node_selector_enabled: false, so the privileged plugin DaemonSet is not limited to the AMD node_selector labels documented in the chart. Add a Helm selector override, such as --set node_selector_enabled=true --set stringArrayValues=node_selector={feature.node.kubernetes.io/pci-0300_1002.present=true,kubernetes.io/arch=amd64}, to both the English and mirrored Chinese instructions.

📍 Affects 2 files
  • docs/userguide/amd-device/enable-amd-gpu-sharing.md#L76-L83 (this comment)
  • i18n/zh/docusaurus-plugin-content-docs/current/userguide/amd-device/enable-amd-gpu-sharing.md#L77-L84
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/userguide/amd-device/enable-amd-gpu-sharing.md` around lines 76 - 83,
Update the Helm installation commands in
docs/userguide/amd-device/enable-amd-gpu-sharing.md lines 76-83 and
i18n/zh/docusaurus-plugin-content-docs/current/userguide/amd-device/enable-amd-gpu-sharing.md
lines 77-84 to enable node selectors and restrict the DaemonSet to AMD GPU nodes
using the documented AMD PCI label and amd64 architecture selector.


If the GHCR package is private in your environment, configure `imagePullSecrets`. You can also clone the repository and install from `./helm/amd-gpu`.

Wait for the DaemonSet:

```bash
kubectl -n kube-system rollout status ds/amd-gpu-device-plugin-daemonset
```

Confirm the device-plugin registered full device info with HAMi:

```bash
kubectl get node <node-name> -o jsonpath='{.metadata.annotations.hami\.io/node-amd-register}'
```

The result must include `devmem` and `devcore`. Example for MI300X VF:

```json
[
{
"id": "8eff74b5-0000-1000-801b-b56457addd1b",
"index": 0,
"count": 10,
"devmem": 196288,
"devcore": 304,
"type": "AMD Instinct MI300X VF",
"numa": 0,
"health": true,
"devicevendor": "amd",
"custominfo": {
"pciBDF": "0000:83:00.0"
}
}
]
```

## Running AMD vGPU Jobs

Request AMD GPUs with `amd.com/gpu`, `amd.com/gpumem`, and `amd.com/gpucores`:

- `amd.com/gpu`: number of AMD GPUs
- `amd.com/gpumem`: device memory quota per GPU, in MiB
- `amd.com/gpucores`: CU quota percentage per GPU, range 0-100; for example `25` allocates about 76 CUs on a 304-CU device

Use a glibc workload image that meets the `GLIBC_2.34` requirement above (for example a recent `rocm/pytorch` tag):

```yaml
apiVersion: v1
kind: Pod
metadata:
name: amd-vgpu-example
spec:
schedulerName: hami-scheduler
restartPolicy: Never
containers:
- name: pytorch
image: rocm/pytorch:latest
command: ["bash", "-c"]
args:
- |
env | grep -E 'LD_AUDIT|HIP_DEVICE_MEMORY_LIMIT'
python3 -c 'import torch; print(torch.cuda.mem_get_info(0)); print(torch.cuda.get_device_name(0))'
sleep 300
resources:
requests:
amd.com/gpu: 1
amd.com/gpumem: 49152
amd.com/gpucores: 25
limits:
amd.com/gpu: 1
amd.com/gpumem: 49152
amd.com/gpucores: 25
```

```bash
kubectl apply -f amd-vgpu-example.yaml
kubectl get pod amd-vgpu-example -o wide
kubectl logs amd-vgpu-example
```

On success, logs look like:

```text
LD_AUDIT=/usr/local/vgpu/libamvgpu.so
HIP_DEVICE_MEMORY_LIMIT=49152m
(51539607552, 51539607552)
AMD Instinct MI300X VF
```

`51539607552` is bytes, about 48 GiB. You can submit two identical 48 GiB / 25% CU workloads to verify sharing.

## Troubleshooting

| Symptom | Action |
| --- | --- |
| `node unregistered` | Check that `amd-device-plugin` is running and `hami.io/node-amd-register` contains `devmem` and `devcore`. Restart the DaemonSet if needed. |
| `CardInsufficientMemory` | The Pod requests more memory than the device has free. Lower `amd.com/gpumem` or wait for other workloads to finish. |
| `insufficient free CUs` | Delete finished AMD vGPU test Pods and restart `amd-device-plugin` to clear stale allocations. |
| Memory inside the container still shows the full physical size | Check that the Pod env includes `LD_AUDIT` and `HIP_DEVICE_MEMORY_LIMIT`, and that the workload image has a compatible glibc. |
| Workload fails to start / cannot load `libamvgpu.so` | Switch to a glibc image with `GLIBC_2.34` or newer. musl/Alpine and older distros are not supported yet. |

Clean up after testing:

```bash
kubectl delete pod amd-vgpu-example
```

## Notes

1. Deploy [amd-device-plugin](https://github.com/Project-HAMi/amd-device-plugin) `0.0.1` or newer (`ghcr.io/project-hami/amd-device-plugin`).
2. Keep the AMD GPU Operator native device-plugin disabled while using HAMi AMD soft vGPU sharing.
3. Omitting `amd.com/gpucores` allocates all CUs on each requested GPU.
4. The bundled `libamvgpu.so` delivery is temporary and will move to `amd-hami-core` once that project publishes a consumption pipeline.
31 changes: 31 additions & 0 deletions docs/userguide/amd-device/examples/allocate-core-and-memory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Allocate device core and memory resource
---

To allocate part of an AMD GPU, set `amd.com/gpucores` and `amd.com/gpumem` together with the number of GPUs in `amd.com/gpu`.

The example below requests one GPU with 48 GiB device memory and 25% compute units:

```yaml
apiVersion: v1
kind: Pod
metadata:
name: amd-vgpu-example
spec:
schedulerName: hami-scheduler
restartPolicy: Never
containers:
- name: pytorch
image: rocm/pytorch:latest
command: ["bash", "-c"]
args:
- |
env | grep -E 'LD_AUDIT|HIP_DEVICE_MEMORY_LIMIT'
python3 -c 'import torch; print(torch.cuda.mem_get_info(0)); print(torch.cuda.get_device_name(0))'
sleep 300
resources:
limits:
amd.com/gpu: 1 # requesting one AMD GPU
amd.com/gpumem: 49152 # each GPU requires 49152 MiB device memory
amd.com/gpucores: 25 # each GPU uses 25% of total compute units
```
1 change: 1 addition & 0 deletions docs/userguide/device-supported.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ The table below lists the devices supported by HAMi:
| XPU | Kunlunxin | P800 | Yes | Yes | No |
| GPU | Vastai | VA16 | Yes | Yes | No |
| GPU | Biren | Biren166M | Yes | Yes | No |
| GPU | AMD | Instinct / ROCm | Yes | Yes | No |
| DPU | Teco | Checking | In progress | In progress | No |
8 changes: 8 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
"message": "共享燧原 GCU 设备",
"description": "The label for category 'Share Enflame GCU devices' in sidebar 'docs'"
},
"sidebar.docs.category.Share AMD GPU devices": {
"message": "共享 AMD GPU 设备",
"description": "The label for category 'Share AMD GPU devices' in sidebar 'docs'"
},
"sidebar.docs.category.amd-examples": {
"message": "示例",
"description": "The label for category 'Examples' in sidebar 'docs'"
},
"sidebar.docs.category.Share MetaX GPU devices": {
"message": "共享沐曦 GPU 设备",
"description": "The label for category 'Share MetaX GPU devices' in sidebar 'docs'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ sidebar_label: 路线图
- [ ] 丰富的可观测性支持
- [x] 支持 DRA
- [ ] 支持 Intel GPU 设备
- [ ] 支持 AMD GPU 设备
- [x] 支持 AMD GPU 设备
- [x] 支持 Enflame GCU 设备
Loading