host-setup: detect driver via device nodes, not lsmod

Second live-host failure: on kernels with amdgpu/amdkfd built-in (=y),
lsmod never lists them and modprobe exits 0 trivially — the old check
falsely reported a missing driver on a fully functional stack.

New logic: /dev/kfd + renderD* presence is the source of truth; module
load is only attempted when nodes are absent; builtins detected via
/sys/module. Also fixes chmod: script ships non-executable from git,
so README now instructs 'bash host-setup.sh' instead of './'.

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
John Smith
2026-08-24 18:30:16 -04:00
co-authored by Claude
parent fc7e5da0cc
commit 95b90f7821
2 changed files with 36 additions and 12 deletions
+2 -1
View File
@@ -45,9 +45,10 @@ Key design decisions and why:
### Phase 1 — Proxmox host
```bash
# physical first: host/oculink-checklist.md (DEG1 DIP switches, power-before-POST, BIOS)
cd proxmox-llm/host && sudo ./host-setup.sh # grub + udev, idempotent, --check available
cd proxmox-llm && sudo bash host/host-setup.sh # grub + udev, idempotent, --check available
sudo reboot # only if grub changed
cat /proc/cmdline # verify flags landed
ls -l /dev/kfd /dev/dri/ # kfd + 2 render nodes must exist
```
### Phase 2 — LXC container
+34 -11
View File
@@ -28,17 +28,40 @@ die() { printf '[host-setup] ERROR: %s\n' "$*" >&2; exit 1; }
command -v grub-editenv >/dev/null 2>&1 || true # informational only
[[ -f /etc/default/grub ]] || die "/etc/default/grub missing"
log "checking kernel modules..."
for mod in amdgpu amdkfd; do
if lsmod | grep -q "^${mod} "; then
log " ${mod}: loaded"
else
log " ${mod}: NOT loaded — attempting modprobe"
(( CHECK_ONLY )) || modprobe "$mod" || die "failed to load $mod; GPU present? see oculink-checklist.md"
lsmod | grep -q "^${mod} " || die "$mod still not loaded — check dmesg / OCuLink power sequencing"
fi
done
[[ -e /dev/kfd ]] || die "/dev/kfd does not exist even with amdkfd loaded — unexpected"
log "checking GPU driver stack..."
# Reality check first: if the device nodes exist, the stack is functional —
# regardless of whether amdgpu/amdkfd are loadable modules (visible in lsmod)
# or built into the kernel (=y; invisible in lsmod but present in /sys/module).
driver_ok() {
[[ -e /dev/kfd ]] || return 1
compgen -G '/dev/dri/renderD*' >/dev/null || return 1
return 0
}
if driver_ok; then
log " device nodes present (/dev/kfd + $(compgen -G '/dev/dri/renderD*' | wc -l) render node(s))"
else
# Nodes missing — now try to load modules explicitly (covers =m configs
# where nothing has triggered a load yet).
log " device nodes missing — attempting explicit module load"
for mod in amdgpu amdkfd; do
if lsmod | grep -q "^${mod} "; then
log " ${mod}: module loaded"
elif [[ -d "/sys/module/${mod}" ]]; then
log " ${mod}: built into kernel"
else
log " ${mod}: not active — attempting modprobe"
(( CHECK_ONLY )) || modprobe "$mod" || true
if lsmod | grep -q "^${mod} " || [[ -d "/sys/module/${mod}" ]]; then
log " ${mod}: active after modprobe"
else
die "${mod} inactive and /dev/kfd absent — GPU enumerated? see oculink-checklist.md; diagnose with 'modprobe -v $mod' + dmesg"
fi
fi
done
sleep 2 # udev settle time for node creation after kfd init
driver_ok || die "/dev/kfd or render nodes still missing after module load — check 'dmesg | grep -iE \"amdgpu|kfd\"'"
fi
# --------------------------------------------------------- ttm sizing ------
RAM_KB=$(awk '/MemTotal/ {print $2}' /proc/meminfo)