Skip to content

Commit 98e67bf

Browse files
committed
Add Lab 7: GPU isolation on k3s without the GPU Operator
Adds a new hands-on lab (English + Chinese) that builds a single-node k3s cluster on a cloud GPU VM, installs HAMi without the NVIDIA GPU Operator with nvidia as the default containerd runtime, and proves memory isolation end to end: virtualized nvidia-smi inside each pod, a CUDA allocation refused at the slice by HAMi-core, an oversubscribing pod kept Pending with CardInsufficientMemory, and the libvgpu.so /etc/ld.so.preload injection mechanism. Every output was captured from a live run on a GCP g4-standard-48 Spot VM with one 96 GB NVIDIA RTX PRO 6000 Blackwell (k3s v1.36.2+k3s1, HAMi v2.9.0, driver 610.43.02). The lab design is adapted from Lovedeep Singh's (@ld-singh) AI Factory Operations Lab with his permission, credited in the lab. Closes #559 Signed-off-by: Saiyam Pathak <saiyam911@gmail.com>
1 parent ac57fe3 commit 98e67bf

7 files changed

Lines changed: 840 additions & 2 deletions

File tree

i18n/zh/docusaurus-plugin-content-docs-tutorials/current/labs/hami-isolation-k3s.md

Lines changed: 385 additions & 0 deletions
Large diffs are not rendered by default.

i18n/zh/docusaurus-plugin-content-docs-tutorials/current/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ import LabCardGridAuto from '@site/src/components/labs/LabCardGridAuto';
1919

2020
<LabCardGridAuto />
2121

22-
每个实验都列出了各自的前提条件。实验 3 和 4 直接复用实验 1 搭建的集群,一次开机即可完成全部三个实验;实验 2 可在任意笔记本上运行,无需 GPU。
22+
每个实验都列出了各自的前提条件。实验 3 和 4 直接复用实验 1 搭建的集群,一次开机即可完成全部三个实验;实验 2 可在任意笔记本上运行,无需 GPU。实验 7 在租用的 GPU 虚拟机上自行搭建单节点 k3s 集群,不使用 GPU Operator。

sidebars-tutorials.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ module.exports = {
4141
id: "labs/hami-vllm",
4242
customProps: { level: "Intermediate", duration: "about 45 minutes" },
4343
},
44+
{
45+
type: "doc",
46+
id: "labs/hami-isolation-k3s",
47+
customProps: { level: "Intermediate", duration: "about 45 minutes" },
48+
},
4449
],
4550
},
4651
],
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# A third Pod whose memory slice fits the card when it is empty, but NOT alongside
2+
# the two 8000 MiB slices that hami-share-a / hami-share-b already hold. It stays
3+
# Pending with CardInsufficientMemory - proving the device plugin and scheduler
4+
# account the card's memory as one shared, finite budget.
5+
#
6+
# Apply this ONLY after hami-share-a and hami-share-b are Running.
7+
#
8+
# Sizing (IMPORTANT - adjust for your card): set gpumem ABOVE (card_total - 2*slice)
9+
# so it cannot fit beside the two slices, and BELOW card_total so it WOULD fit on an
10+
# empty card. 90000 MiB works for a 96 GB RTX PRO 6000 (97887 MiB) with two 8000 MiB
11+
# slices held (~82000 free). For a 48 GB card use ~45000; for a 24 GB card with two
12+
# 4000 MiB slices, use ~20000.
13+
# Read the card size first:
14+
# kubectl exec hami-share-a -- nvidia-smi --query-gpu=memory.total --format=csv
15+
apiVersion: v1
16+
kind: Pod
17+
metadata:
18+
name: hami-oversubscribe
19+
spec:
20+
restartPolicy: Never
21+
containers:
22+
- name: cuda
23+
image: nvidia/cuda:12.4.1-devel-ubuntu22.04
24+
command: ["bash", "-c", "nvidia-smi; sleep infinity"]
25+
resources:
26+
limits:
27+
nvidia.com/gpu: 1
28+
nvidia.com/gpumem: 90000
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Two Pods, each asking for one physical GPU and an 8000 MiB memory slice. On a
2+
# 96 GB RTX PRO 6000 (or a 48 GB A6000) both fit with plenty of headroom, so both
3+
# land on the one GPU. On a 24 GB card use ~4000 MiB instead.
4+
#
5+
# The image is the CUDA devel image because the memory probe compiles a tiny CUDA
6+
# allocator with nvcc inside the Pod. It is large to pull; that is expected.
7+
apiVersion: v1
8+
kind: Pod
9+
metadata:
10+
name: hami-share-a
11+
spec:
12+
restartPolicy: Never
13+
containers:
14+
- name: cuda
15+
image: nvidia/cuda:12.4.1-devel-ubuntu22.04
16+
command: ["bash", "-c", "nvidia-smi; sleep infinity"]
17+
resources:
18+
limits:
19+
nvidia.com/gpu: 1
20+
nvidia.com/gpumem: 8000
21+
---
22+
apiVersion: v1
23+
kind: Pod
24+
metadata:
25+
name: hami-share-b
26+
spec:
27+
restartPolicy: Never
28+
containers:
29+
- name: cuda
30+
image: nvidia/cuda:12.4.1-devel-ubuntu22.04
31+
command: ["bash", "-c", "nvidia-smi; sleep infinity"]
32+
resources:
33+
limits:
34+
nvidia.com/gpu: 1
35+
nvidia.com/gpumem: 8000

0 commit comments

Comments
 (0)