Skip to content

Add Lab 7: GPU isolation on k3s without the GPU Operator#560

Merged
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
saiyam1814:add-hami-isolation-lab
Jul 8, 2026
Merged

Add Lab 7: GPU isolation on k3s without the GPU Operator#560
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
saiyam1814:add-hami-isolation-lab

Conversation

@saiyam1814

@saiyam1814 saiyam1814 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What this PR adds

A new hands-on tutorial, Lab 7: GPU Isolation on k3s Without the GPU Operator (English + Chinese), plus example manifests and sidebar wiring.

The lab builds a single-node k3s cluster on a cloud GPU VM, installs HAMi without the NVIDIA GPU Operator (HAMi's own device plugin, nvidia as the default containerd runtime), and proves memory isolation end to end:

  • Two Pods co-resident on one physical GPU with 8000 MiB gpumem slices
  • Virtualized nvidia-smi inside each Pod (8000 MiB shown on a 97887 MiB card)
  • A CUDA allocation refused by HAMi-core at the slice (Device 0 OOM 8629780480 / 8388608000) while ~82 GB was physically free
  • An oversubscribing Pod kept Pending with CardInsufficientMemory
  • The mechanism surfaced: libvgpu.so via /etc/ld.so.preload + CUDA_DEVICE_MEMORY_LIMIT_0

How it differs from Lab 3

Lab 3 proves isolation on the GPU Operator path; this lab covers the other supported path (no Operator, k3s, default runtime) used on edge nodes, bare metal, and rented GPU VMs — and it exposes the injection mechanism that path hides.

Provenance and verification

  • Every output was captured from a live run on 2026-07-07: GCP g4-standard-48 Spot VM, one 96 GB NVIDIA RTX PRO 6000 Blackwell, k3s v1.36.2+k3s1, HAMi v2.9.0, driver 610.43.02 (open kernel modules).
  • The lab design is adapted, with his kind permission, from @ld-singh's AI Factory Operations Lab — credited in the lab with links to his course and his original A6000 validation report. The no-GPU scheduling half of his lesson is already covered by Lab 2.
  • npm run build passes for both locales.

Closes #559

Summary by CodeRabbit

  • New Features
    • Added a new Chinese Lab 7 tutorial for enabling GPU isolation on a standalone single-node k3s cluster without the GPU Operator.
    • Added Lab 7 to the tutorials sidebar and updated the Labs overview description.
    • Introduced new example Pod manifests to demonstrate shared GPU memory slicing and GPU memory oversubscription remaining Pending when insufficient.
  • Documentation
    • Included step-by-step setup, verification expectations, and cleanup/uninstall guidance for the end-to-end lab flow.

@netlify

netlify Bot commented Jul 7, 2026

Copy link
Copy Markdown

Deploy Preview for project-hami ready!

Name Link
🔨 Latest commit 5e7e2dc
🔍 Latest deploy log https://app.netlify.com/projects/project-hami/deploys/6a4e09591b4ff600083e1fb1
😎 Deploy Preview https://deploy-preview-560--project-hami.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hami-robot hami-robot Bot requested review from rootsongjc and wawa0210 July 7, 2026 10:48
@hami-robot hami-robot Bot added the size/XL label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2431b18-bc51-4c8a-b431-4088cc9b9767

📥 Commits

Reviewing files that changed from the base of the PR and between f313736 and 5e7e2dc.

📒 Files selected for processing (1)
  • tutorials/labs/hami-isolation-k3s.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • tutorials/labs/hami-isolation-k3s.md

📝 Walkthrough

Walkthrough

This PR adds a new Lab 7 tutorial for GPU isolation on k3s without the GPU Operator, plus supporting sidebar, overview, manifest, and Chinese translation updates.

Changes

Lab 7 Tutorial Addition

Layer / File(s) Summary
Sidebar entry and overview mentions
sidebars-tutorials.js, tutorials/overview.md, i18n/zh/.../overview.md
Adds a Labs sidebar doc item for labs/hami-isolation-k3s and updates both overview pages to mention Lab 7’s standalone k3s setup without the GPU Operator.
English lab intro and prerequisites
tutorials/labs/hami-isolation-k3s.md
Adds front matter, intro, Lab 3 comparison, learning goals, overview flowchart, prerequisites, and a warning not to install the GPU Operator.
English host, runtime, and HAMi setup
tutorials/labs/hami-isolation-k3s.md
Adds steps for driver verification, Container Toolkit and k3s installation, default runtime configuration, and HAMi installation plus validation.
English isolation proof and manifests
tutorials/labs/hami-isolation-k3s.md, tutorials/labs/examples/07-hami-isolation-k3s/share-two-pods.yaml, tutorials/labs/examples/07-hami-isolation-k3s/oversubscribe-pending.yaml
Adds the shared-pod and oversubscription manifests and the lab steps that verify slice limits, scheduling behavior, and mechanism inspection.
English cleanup, summary, and credits
tutorials/labs/hami-isolation-k3s.md
Adds cleanup commands, a claims/evidence table, next-step links, and credits.
Chinese translation of Lab 7
i18n/zh/docusaurus-plugin-content-docs-tutorials/current/labs/hami-isolation-k3s.md
Adds the full Chinese version of the lab across intro, setup, proof, cleanup, and credits sections.

Estimated code review effort: 2 (Simple) | ~12 minutes

Suggested labels: lgtm, approved

Suggested reviewers: rootsongjc, wawa0210

Poem

A rabbit hops through GPU clouds so bright,
Two pods share one slice, then hold it tight.
k3s hums along, no Operator in sight,
HAMi keeps the memory limits just right. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Lab 7 for GPU isolation on k3s without the GPU Operator.
Linked Issues check ✅ Passed The PR adds the requested lab and website integration for GPU isolation on k3s without the GPU Operator, matching #559.
Out of Scope Changes check ✅ Passed The added docs, manifests, and sidebar updates all support the new lab and do not introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@hami-robot

hami-robot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: saiyam1814

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
tutorials/labs/examples/07-hami-isolation-k3s/share-two-pods.yaml (1)

13-20: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Consider basic pod hardening for copy-paste safety.

Static analysis flags missing allowPrivilegeEscalation: false and non-root securityContext on both containers. Since readers may copy this manifest into shared or production-adjacent clusters, adding minimal hardening avoids propagating an insecure default pattern.

🔒️ Optional hardening
     - name: cuda
       image: nvidia/cuda:12.4.1-devel-ubuntu22.04
       command: ["bash", "-c", "nvidia-smi; sleep infinity"]
+      securityContext:
+        allowPrivilegeEscalation: false
       resources:
         limits:
           nvidia.com/gpu: 1
           nvidia.com/gpumem: 8000

Also applies to: 28-35

🤖 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 `@tutorials/labs/examples/07-hami-isolation-k3s/share-two-pods.yaml` around
lines 13 - 20, The pod spec in the shared examples is missing basic hardening
defaults, so update both container definitions (including the cuda container and
the other container in this manifest) to run as non-root and prevent privilege
escalation. Add a minimal securityContext for each container with
allowPrivilegeEscalation set to false and a non-root runAsUser/runAsNonRoot
setting so the copied manifest is safer by default.

Source: Linters/SAST tools

🤖 Prompt for all review comments with 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.

Inline comments:
In
`@i18n/zh/docusaurus-plugin-content-docs-tutorials/current/labs/hami-isolation-k3s.md`:
- Around line 1-385: The document has formatting drift and needs to be
reformatted consistently with the repository’s Prettier settings. Run Prettier
on the Markdown tutorial content in this file and keep the existing wording
unchanged; focus only on whitespace, wrapping, and markdown formatting so the
doc matches CI expectations.

In `@i18n/zh/docusaurus-plugin-content-docs-tutorials/current/overview.md`:
- Line 22: The lab list and the following explanatory text are currently in the
same paragraph, which is fragile for the block-level LabCardGridAuto rendering.
Update the overview content so the experiment list remains one paragraph and
move the trailing explanation about experiments 3, 4, 2, and 7 into its own
separate paragraph in the same MDX section.

In `@tutorials/labs/hami-isolation-k3s.md`:
- Around line 19-21: Reflow the opening prose in this lab so it matches the
documentation line-length/style rules and passes prettier --check. Update the
introductory paragraphs in the tutorial content itself, keeping the same meaning
while wrapping the long sentences more cleanly in the opening section of
hami-isolation-k3s.md.

In `@tutorials/overview.md`:
- Line 20: Separate the LabCardGridAuto block from the explanatory prose by
putting the text in its own paragraph in the overview content. Update the MDX
around LabCardGridAuto so it stands alone as a block, then keep the labs
description as a separate paragraph immediately after it, preserving the
existing wording and references to the lab prerequisites.

---

Nitpick comments:
In `@tutorials/labs/examples/07-hami-isolation-k3s/share-two-pods.yaml`:
- Around line 13-20: The pod spec in the shared examples is missing basic
hardening defaults, so update both container definitions (including the cuda
container and the other container in this manifest) to run as non-root and
prevent privilege escalation. Add a minimal securityContext for each container
with allowPrivilegeEscalation set to false and a non-root runAsUser/runAsNonRoot
setting so the copied manifest is safer by default.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c8e85ac-e55c-414c-a08f-a2364b590a4c

📥 Commits

Reviewing files that changed from the base of the PR and between ac57fe3 and 98e67bf.

📒 Files selected for processing (7)
  • i18n/zh/docusaurus-plugin-content-docs-tutorials/current/labs/hami-isolation-k3s.md
  • i18n/zh/docusaurus-plugin-content-docs-tutorials/current/overview.md
  • sidebars-tutorials.js
  • tutorials/labs/examples/07-hami-isolation-k3s/oversubscribe-pending.yaml
  • tutorials/labs/examples/07-hami-isolation-k3s/share-two-pods.yaml
  • tutorials/labs/hami-isolation-k3s.md
  • tutorials/overview.md

<LabCardGridAuto />

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

将实验列表和后面的说明拆成独立段落。

LabCardGridAuto 会渲染成块级元素,和说明文字写在同一行会导致 MDX 结构不够稳妥。请把后面的说明单独放到一个段落里。

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
每个实验都列出了各自的前提条件。实验 3 和 4 直接复用实验 1 搭建的集群,一次开机即可完成全部三个实验;实验 2 可在任意笔记本上运行,无需 GPU。实验 7 在租用的 GPU 虚拟机上自行搭建单节点 k3s 集群,不使用 GPU Operator。
每个实验都列出了各自的前提条件。实验 3 和 4 直接复用实验 1 搭建的集群,一次开机即可完成全部三个实验;实验 2 可在任意笔记本上运行,无需 GPU。实验 7 在租用的 GPU 虚拟机上自行搭建单节点 k3s 集群,不使用 GPU Operator。
🤖 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 `@i18n/zh/docusaurus-plugin-content-docs-tutorials/current/overview.md` at line
22, The lab list and the following explanatory text are currently in the same
paragraph, which is fragile for the block-level LabCardGridAuto rendering.
Update the overview content so the experiment list remains one paragraph and
move the trailing explanation about experiments 3, 4, 2, and 7 into its own
separate paragraph in the same MDX section.

Source: Linked repositories

Comment thread tutorials/labs/hami-isolation-k3s.md Outdated
Comment thread tutorials/overview.md
## Labs

<LabCardGridAuto /> Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required.
<LabCardGridAuto /> Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required. Lab 7 brings up its own single-node k3s cluster on a rented GPU VM, without the GPU Operator.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Separate the labs grid from the following paragraph.

LabCardGridAuto renders a block element, so keeping prose on the same line can produce awkward MDX output. Put the explanatory text in its own paragraph.

♻️ Proposed fix
-<LabCardGridAuto /> Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required. Lab 7 brings up its own single-node k3s cluster on a rented GPU VM, without the GPU Operator.
+<LabCardGridAuto />
+
+Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required. Lab 7 brings up its own single-node k3s cluster on a rented GPU VM, without the GPU Operator.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<LabCardGridAuto /> Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required. Lab 7 brings up its own single-node k3s cluster on a rented GPU VM, without the GPU Operator.
<LabCardGridAuto />
Each lab lists its own prerequisites. Labs 3 and 4 continue from the cluster Lab 1 builds, so a single session covers all three; Lab 2 runs on any laptop with no GPU required. Lab 7 brings up its own single-node k3s cluster on a rented GPU VM, without the GPU Operator.
🤖 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 `@tutorials/overview.md` at line 20, Separate the LabCardGridAuto block from
the explanatory prose by putting the text in its own paragraph in the overview
content. Update the MDX around LabCardGridAuto so it stands alone as a block,
then keep the labs description as a separate paragraph immediately after it,
preserving the existing wording and references to the lab prerequisites.

Source: Linked repositories

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 Project-HAMi#559

Signed-off-by: Saiyam Pathak <saiyam911@gmail.com>
@saiyam1814 saiyam1814 force-pushed the add-hami-isolation-lab branch from 98e67bf to f313736 Compare July 7, 2026 11:31
@hami-robot hami-robot Bot removed the lgtm label Jul 7, 2026
@mesutoezdil

Copy link
Copy Markdown
Contributor

thx, pls replace the em dashes (—) with regular hyphens or commas. our repo's style rule:

https://github.com/Project-HAMi/website/blob/master/docs/contributor/contribute-docs.md#writing-style

everything else here looks good, good numbering, full zh translation, correct sidebar entry, thx for this lab.

Signed-off-by: Saiyam Pathak <saiyam911@gmail.com>
@saiyam1814

Copy link
Copy Markdown
Contributor Author

@mesutoezdil em dashes fixed

@mesutoezdil

Copy link
Copy Markdown
Contributor

@mesutoezdil em dashes fixed

thx mate!

@mesutoezdil

Copy link
Copy Markdown
Contributor

/lgtm

@hami-robot hami-robot Bot added the lgtm label Jul 8, 2026
@hami-robot hami-robot Bot merged commit 5f2a730 into Project-HAMi:master Jul 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a lab - https://ld-singh.github.io/ai-factory-ops-lab/portfolio-lab/01-k8s-gpu-platform/hami/

2 participants