Files

55 lines
5.0 KiB
Markdown

# Design — add-mi50-gpu-support
## Context
- Host: bigbox, Ubuntu 24.04.4 LTS, kernel 6.8.0-142-generic (active) / 6.8.0-146-generic (installed, not active), UEFI boot.
- PCI GPUs today: 04:00.0 NVIDIA 5060 Ti (2d04, nvidia driver), 07:00.0 ASPEED (ast module available, not bound now — console on efifb).
- GRUB cmdline: `quiet splash video=1920x1080 fbcon=rotate:1 nomodeset` — remove `nomodeset` (blocks amdgpu entirely: no /dev/dri, no /dev/kfd) and `fbcon=rotate:1` (user Q3).
- amdgpu: module present; amdkfd BUILT-IN (CONFIG_HSA_AMD=y, CONFIG_HSA_AMD_SVM=y, CONFIG_HSA_AMD_P2P=y) — no amdgpu-dkms needed; /dev/kfd appears automatically when amdgpu loads.
- vega20 firmware: present in linux-firmware (674 files under /lib/firmware/amdgpu/).
- NVIDIA: dkms nvidia/595.99.02 built for both kernels; loaded module 595.84 → mismatch (`nvidia-smi` fails). Fix: rebuild dkms for active kernel, remove stale module, reload.
- Docker 29.4.2, data-root /var/lib/docker (currently small — 4 KB? real data on volumes; `docker system df` shows 50 GB images + 2 GB build cache; system df -v: images table lists ROOT occupied). Root md0: 97% full (8.4 GB free).
- /opt/backup: NVMe nvme0n1p1, 916 GB, 141 GB used, 730 GB available. Already holds docker-ish data (ollama-data, open-webui-data, registry, archives).
- groups: render 993 exists; udev rule `SUBSYSTEM=="kfd", GROUP="render", MODE="0660"` present. user estorozhenko — needs membership in render (+ video) for /dev/kfd access outside root.
## Decisions
### D1: Remove nomodeset from primary GRUB entry; add recovery entry
- Primary: `quiet splash video=1920x1080` (no nomodeset, no fbcon=rotate:1).
- Add a menu entry `Ubuntu (nomodeset safe mode)` copying the current boot params + `nomodeset` (+ optionally `systemd.unit=multi-user.target` for console).
- `GRUB_TIMEOUT_STYLE=menu`, `GRUB_TIMEOUT=10` (was hidden/0) so the menu is always reachable.
- Recovery entry implemented via `/etc/grub.d/40_custom` (persists across update-grub), referencing the same kernel/initrd by stable names.
- Apply with `update-grub` only after user confirmation; verify with `grub-editenv list` / `grep menuentry /boot/grub/grub.cfg`.
### D2: Fix NVIDIA mismatch (keep 595-open for 5060 Ti)
- `sudo dkms install nvidia/595.99.02 -k 6.8.0-142-generic --force` (and -146).
- `sudo modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia` then `sudo modprobe nvidia` (or reboot).
- Verify `nvidia-smi` returns; 5060 Ti enumerated.
### D3: Relocate Docker data-root to /opt/backup/docker
- Stop Docker: `systemctl stop docker` (also `containerd` if needed; safest: `systemctl stop docker`).
- `rsync -aHAX /var/lib/docker/ /opt/backup/docker/` (exclude nothing; data is 50 GB — runtime ~10-20 min).
- Update `/etc/docker/daemon.json` → `"data-root": "/opt/backup/docker"`.
- Start Docker; verify `docker info` shows new root; `docker ps` all containers up.
- Keep old /var/lib/docker until verified ok, then remove (with user confirmation — deletion is user-data-touching; keep as /var/lib/docker.old until confirmed).
- Container device access for ROCm: daemon.json keeps nvidia runtime; AMD containers need `--device /dev/kfd --device /dev/dri` (passed per-container, no daemon change required). Optionally add user estorozhenko to `render` group for non-root /dev/kfd access.
### D4: Prepare host for MI50 without installing amdgpu-dkms
- Verify current kernel has amdgpu module + kfd builtin (already confirmed). No ROCm driver install on host; everything GPU-side runs in Docker image.
- Firmware vega20 present; if missing, `apt install --reinstall linux-firmware`.
## Risks & Mitigations
- amdgpu binds at boot and delays/fails -> recovery entry with nomodeset always selectable (menu timeout 10s), console via ASPEED.
- Multi-GPU probe order / console: amdgpu may claim console via efifb; ASPEED ast not bound now — after removing nomodeset, ast may bind and take console; acceptable (BMC KVM console works). fbcon=rotate removed is user choice.
- Docker migration: daemon-down window; if rsync interrupted, restart rsync (idempotent); old data-root kept until verified.
- NVIDIA mismatch: rebuild dkms; if module fails to load, fall back to previous installed dkms version (595.99.02 is installed for both kernels — just needs reinstall).
- Disk: after migration ~50 GB freed on md0; ROCm image (~15-20 GB) lands on NVMe.
## Verification Plan
1. GRUB: `grep -E '^menuentry' /boot/grub/grub.cfg` shows default (no nomodeset) + recovery entry; `grub-editenv list` default set.
2. Boot: after reboot, `cat /proc/cmdline` has no nomodeset; `ls /dev/dri` shows card/renderD; with MI50 installed `/dev/kfd` exists.
3. NVIDIA: `nvidia-smi` OK; `/proc/driver/nvidia/version` matches userspace 595.99.
4. Docker: `docker info --format '{{.DockerRootDir}}'` = /opt/backup/docker; `docker ps` healthy; md0 free space increased.
5. ROCm container smoke (post-hardware-install): pull community gfx906 image; `docker run --device /dev/kfd --device /dev/dri` + `/opt/rocm/bin/rocm-smi` shows 2x MI50; HSA_OVERRIDE_GFX_VERSION=9.0.6 documented.