Files
project-lyra/docs/MI50_STACK.md
T

163 lines
7.4 KiB
Markdown

# How the MI50 Runs
**Host:** `proxmox` · 10.0.0.4 · card at `0000:0a:00.0`
**Companion doc:** [`MI50_MAINTENANCE.md`](../MI50_MAINTENANCE.md) — full configuration inventory, upgrade and rollback procedures.
**Rendered version:** https://claude.ai/code/artifact/7744ae19-f125-4a00-bb51-7e08d9a74767
A 2018 datacenter accelerator serving a 32B model, reached through four layers that each think they own the GPU. One idea explains why the version numbers look wrong.
| | |
|---|---|
| **Card** | MI50 · gfx906 |
| **Host kernel** | 6.1.10-1-pve |
| **ROCm (serving)** | 6.3.3 |
| **VRAM in use** | 24.2 / 32 GB |
| **Junction** | 41 °C |
*Observed read-only from the running host, 2026-09-09.*
---
## The one idea
### ROCm is split in half, and the halves version separately
ROCm isn't one piece of software. It's a **kernel half** — `amdgpu` and KFD, compiled into the kernel, owning the card and its memory — and a **userspace half**: the HSA runtime, HIP, rocBLAS. Ordinary files sitting in `/opt/rocm`.
An LXC container shares the host's kernel. So it needs no driver of its own — only the *device nodes*. It brings its own userspace half and talks straight to the host's kernel half.
That's the whole trick. A ROCm 6.3 userspace from late 2024 is driving an `amdgpu` built in February 2023, and it works because the KFD ioctl interface is backward-compatible.
```mermaid
flowchart TD
subgraph US["USERSPACE HALF — ships inside containers"]
direction TB
D["docker · lyra-brain<br/>llama.cpp + libggml-hip.so, built for gfx906<br/>ROCm 6.3.3-74 — its own copy, this is what serves"]
L["lxc ct202 · gpu-jammy<br/>Ubuntu 22.04 · privileged · shares the host kernel<br/>ROCm 6.3.0-39 — diagnostics only, not serving"]
N["/dev/kfd 510:0 — compute, queues, VRAM<br/>/dev/dri/renderD129 226:129 — buffer allocation<br/>both required"]
end
subgraph KS["KERNEL HALF — one shared driver"]
direction TB
K["host kernel 6.1.10-1-pve<br/>amdgpu · DRM 3.49.0 · KFD topology node vega20<br/>the only kernel driver anywhere in this stack"]
H["MI50 · Vega 20 · gfx906<br/>60 CU · 240 SIMD · 32 GB HBM2 · passively cooled"]
end
D -->|"devices /dev/kfd, /dev/dri"| L
L -->|"bind mount · lxc.mount.entry"| N
N -->|"ioctl · KFD ABI — THE SPLIT"| K
K -->|"PCIe · BAR0 32 GiB at 0x7000000000"| H
```
> Two ROCm userspaces sit above one kernel driver. The Docker image carries the copy that actually serves; the LXC's ROCm 6.3.0 is only ever used by `rocminfo`.
---
## Why this shape
### Passthrough lost because it needed a second kernel
The first attempts handed the whole PCI device to a VM. That means the guest needs its own `amdgpu` — and it needs the card's 32 GiB BAR mapped into guest address space. That mapping was exactly what the firmware was refusing to do.
Sharing device nodes into a container sidesteps both. One kernel, no remap.
```mermaid
flowchart TB
subgraph OLD["ABANDONED — VFIO passthrough"]
direction TB
O1["MI50 · 0000:0a:00.0"]
O2["host · vfio-pci stub"]
O3["guest kernel — a 2nd amdgpu<br/>a whole second driver to maintain"]
O4["ROCm userspace — never reached"]
O1 -->|"bind to vfio-pci"| O2
O2 -.->|"remap 32 GiB BAR — FAILED"| O3
O3 --> O4
end
subgraph NEW["CURRENT — LXC device sharing"]
direction TB
N1["MI50 · 0000:0a:00.0"]
N2["host kernel — the only amdgpu<br/>creates /dev/kfd + /dev/dri"]
N3["container · device nodes"]
N4["ROCm userspace — serving"]
N1 -->|"bind to amdgpu"| N2
N2 -->|"bind mount · no remap"| N3
N3 --> N4
end
```
> The difference is one kernel and one memory remap. The failing edge on the left is the same 32 GiB BAR assignment that the October 2025 logs show failing on bare metal — the BIOS fix, not the container switch, is what finally resolved it.
---
## The part nobody would guess
### The driver loads 48 seconds after the container that needs it
`amdgpu` is deliberately blacklisted so it does *not* autoload at PCI probe. It's modprobed by hand, late, by `load-amdgpu.service` — well after Proxmox has already started CT202.
That should break. It doesn't, because of two lines in a service file that looks like a leftover.
```mermaid
sequenceDiagram
participant S as systemd
participant K as kfd-fix.service
participant C as CT202
participant A as amdgpu
Note over S,A: T+0s — blacklist holds, amdgpu does not load
S->>K: start, After=local-fs.target
K->>C: T+2s — mknod /dev/kfd c 510 0, a placeholder
Note right of K: mount target must already exist
S->>C: T+20s — pve-guests starts CT202
C->>C: binds /dev/kfd and /dev/dri
S->>A: T+68s — load-amdgpu.service runs modprobe amdgpu
A-->>C: real device appears, same inode
Note over C,A: shared mount propagation fills it in, no restart
```
> Delete `kfd-fix.service` as dead weight and the container comes up with no `/dev/kfd` — the `optional` bind silently skips when its target is missing. This is the most deletable-looking load-bearing file on the box.
---
## The cost nobody sees
### The kernel pin caps how far ROCm can advance
> **Unsupported, working.**
> The gap between the kernel half (Feb 2023) and the userspace half (late 2024) is about two years, and AMD does not support that combination. It works only because nothing in ROCm 6.3 yet asks for a KFD ioctl this kernel lacks.
>
> So the pin isn't only a boot-stability decision. The day an image needs a newer KFD interface, inference breaks, and the fix is the kernel question — not a container change. Those two problems are the same problem.
---
## Honest read
### The compute path is textbook. The scaffolding is held together with October assumptions.
**Genuinely solid**
- **The architecture itself.** Host driver plus container device sharing is the standard, recommended way to run ROCm in containers. Not a hack.
- **Self-contained runtime.** The Docker image carries its own ROCm, so the LXC can rot without touching inference.
- **Thermal engineering.** A fan curve driven by junction temperature plus an independent watchdog. Most people run these cards bare and cook them.
- **Track record.** The journal shows three-month uninterrupted uptimes.
**Genuinely janky**
- **EOL kernel.** Pinned to a build from February 2023 that receives no security updates.
- **Booby-trapped filenames.** The load-bearing blacklist is called `blacklist-temp-amdgpu.conf`.
- **Hardcoded dynamic values.** Device major `510` in four files; `hwmon3` in the fan script. Both are allocation-order dependent.
- **Three distro codenames in APT.** bookworm, trixie and jammy sources on one trixie host.
- **Backups invert reality.** The dormant container is backed up nightly; the one actually serving has never been backed up.
The split matters because it tells you where to spend effort. Nothing in the second list is hard to fix, and none of it requires touching the part that took real work to get right.
---
## If it breaks
Four checks, in order:
| Command | What it tells you |
|---|---|
| `dmesg \| grep "0a:00.0.*BAR 0"` | "can't assign" means the BIOS lost Above 4G Decoding |
| `lspci -nnks 0000:0a:00.0` | Want "Kernel driver in use: amdgpu" |
| `grep kfd /proc/devices` | Must still be 510, or the LXC cgroup rule blocks it |
| `cat /sys/class/hwmon/hwmon3/name` | Must be nct6798, or the fans are running blind |