From 95b90f782154da5df2ceef3dde86c47734df2ea4 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 24 Aug 2026 18:30:01 -0400 Subject: [PATCH] host-setup: detect driver via device nodes, not lsmod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README.md | 3 ++- host/host-setup.sh | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7d99688..e39bf2f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/host/host-setup.sh b/host/host-setup.sh index 48740ae..170bff1 100644 --- a/host/host-setup.sh +++ b/host/host-setup.sh @@ -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)