Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(installer): no WSL NVIDIA driver warning when a Windows model server owns the GPU (#8186)

Mike Bradleycca046751499
diff --git a/ods/installers/lib/native-llm.sh b/ods/installers/lib/native-llm.sh
index 395b3dcdc..377b437b5 100644
--- a/ods/installers/lib/native-llm.sh
+++ b/ods/installers/lib/native-llm.sh
@@ -9,8 +9,9 @@
# with --native-llm-url.
#
# Expects: nothing (pure functions)
-# Provides: ods_native_llm_requested(), ods_native_llm_normalize_origin(),
-# ods_native_llm_container_origin(), ods_native_llm_origin_port()
+# Provides: ods_native_llm_requested(), ods_native_llm_owns_host_gpu(),
+# ods_native_llm_normalize_origin(), ods_native_llm_container_origin(),
+# ods_native_llm_origin_port()
#
# Modder notes:
# NATIVE_LLM_BASE_URL is the origin seen from the host (loopback);
@@ -23,6 +24,14 @@ ods_native_llm_requested() {
[[ -n "${NATIVE_LLM_BASE_URL:-}" ]]
}
+# True when a Windows model server owns the host GPU: only Windows setup
+# passes --native-llm-gpu-name with the native route (the AMD GPU on the AMD
+# route). WSL then sees no usable GPU on purpose, so there is no GPU driver
+# for this stack to repair.
+ods_native_llm_owns_host_gpu() {
+ ods_native_llm_requested && [[ -n "${NATIVE_LLM_GPU_NAME:-}" ]]
+}
+
# Print an http origin without a trailing slash or /v1 (/api/v1 from the
# retired Lemonade flags is accepted too). Returns 1 for anything else: a
# query, credentials, another path or a non-numeric port.
diff --git a/ods/installers/phases/02-detection.sh b/ods/installers/phases/02-detection.sh
index 6e92b99b7..1ad98d4bf 100755
--- a/ods/installers/phases/02-detection.sh
+++ b/ods/installers/phases/02-detection.sh
@@ -29,6 +29,8 @@
# native-llm.sh gives install-core: a host-native llama-server is in use.
declare -F ods_native_llm_requested >/dev/null 2>&1 \
|| ods_native_llm_requested() { [[ -n "${NATIVE_LLM_BASE_URL:-}" ]]; }
+declare -F ods_native_llm_owns_host_gpu >/dev/null 2>&1 \
+ || ods_native_llm_owns_host_gpu() { ods_native_llm_requested && [[ -n "${NATIVE_LLM_GPU_NAME:-}" ]]; }
[[ -f "${SCRIPT_DIR:-}/lib/safe-env.sh" ]] && . "$SCRIPT_DIR/lib/safe-env.sh"
. "$SCRIPT_DIR/installers/lib/wsl-memory.sh"
@@ -212,8 +214,11 @@ log "Host architecture: ${HOST_ARCH}"
# Secure Boot + NVIDIA auto-fix
#-----------------------------------------------------------------------------
# If detect_gpu found no working GPU, check if it's a fixable driver/Secure Boot issue
-# (Only for NVIDIA — AMD APU is handled above)
-if [[ "${GPU_BACKEND_FORCED_CPU:-false}" != "true" && $GPU_COUNT -eq 0 && "$GPU_BACKEND" != "amd" ]] && ! $DRY_RUN; then
+# (Only for NVIDIA — AMD APU is handled above). A Windows model server owns
+# the host GPU on purpose, so there is nothing to fix here (and no WSL GPU
+# warning to show).
+if [[ "${GPU_BACKEND_FORCED_CPU:-false}" != "true" && $GPU_COUNT -eq 0 && "$GPU_BACKEND" != "amd" ]] && ! $DRY_RUN \
+ && ! ods_native_llm_owns_host_gpu; then
fix_nvidia_secure_boot || true
fi
diff --git a/ods/tests/ci-suite.txt b/ods/tests/ci-suite.txt
index 2e9396529..e998cbdda 100644
--- a/ods/tests/ci-suite.txt
+++ b/ods/tests/ci-suite.txt
@@ -10,6 +10,7 @@ tests/test-inference-port-admission.sh
tests/contracts/test-amd-llamacpp-contracts.sh
tests/contracts/test-host-native-llm-contracts.sh
tests/contracts/test-host-native-llm-cpu-fallback.sh
+tests/contracts/test-native-llm-gpu-owner.sh
tests/contracts/test-installer-hardening.sh
tests/contracts/test-docs-llama-host-port.sh
tests/contracts/test-llama-metrics-flag.sh
diff --git a/ods/tests/contracts/test-native-llm-gpu-owner.sh b/ods/tests/contracts/test-native-llm-gpu-owner.sh
new file mode 100755
index 000000000..2a54b99db
--- /dev/null
+++ b/ods/tests/contracts/test-native-llm-gpu-owner.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# A Windows model server owns the host GPU when Windows setup passes
+# --native-llm-gpu-name with the native route (today the AMD GPU on the AMD
+# route). WSL then sees no GPU on purpose, so phase 02 must not run the NVIDIA
+# driver repair, which in WSL only prints "NVIDIA GPU access is unavailable in
+# WSL". This checks the predicate (installers/lib/native-llm.sh), the fallback
+# isolated sourcing of phase 02 gets, and the real phase 02 driver repair
+# block that uses it.
+set -euo pipefail
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+PHASE="$ROOT_DIR/installers/phases/02-detection.sh"
+GPU='AMD Radeon RX 9070 XT'
+
+fail() { echo "[FAIL] $*" >&2; exit 1; }
+pass() { echo "[PASS] $*"; }
+
+# shellcheck source=../../installers/lib/native-llm.sh
+source "$ROOT_DIR/installers/lib/native-llm.sh"
+
+owns() (
+ NATIVE_LLM_BASE_URL="$1"
+ NATIVE_LLM_GPU_NAME="$2"
+ if ods_native_llm_owns_host_gpu; then echo yes; else echo no; fi
+)
+[[ "$(owns http://localhost:8080 "$GPU")" == yes ]] || fail "the native route with a Windows GPU name owns the host GPU"
+[[ "$(owns http://localhost:8080 '')" == no ]] || fail "a native route without a Windows GPU name does not claim it"
+[[ "$(owns '' "$GPU")" == no ]] || fail "a GPU name without the native route does not claim it"
+[[ "$(owns '' '')" == no ]] || fail "no native route, no claim"
+pass "ods_native_llm_owns_host_gpu: the native route plus the Windows GPU name, nothing else"
+
+# The definition an isolated phase 02 gets agrees with it.
+phase_fallback="$(awk '/^declare -F ods_native_llm_owns_host_gpu/{p=1} p{print} p && /^ \|\|/{exit}' "$PHASE")"
+[[ "$phase_fallback" == *'ods_native_llm_requested && [[ -n "${NATIVE_LLM_GPU_NAME:-}" ]]'* ]] \
+ || fail "phase 02's fallback predicate must match installers/lib/native-llm.sh"
+pass "isolated phase 02 defines the same predicate"
+
+# Phase 02: no NVIDIA driver repair (and no WSL GPU warning) for that GPU.
+boot_block="$(awk '/^# If detect_gpu found no working GPU, check if/{p=1} p{print} p && /^fi$/{exit}' "$PHASE")"
+[[ "$boot_block" == *'fix_nvidia_secure_boot || true'* ]] || fail "phase 02 driver repair block not found"
+boot() (
+ called=no
+ fix_nvidia_secure_boot() { called=yes; return 1; }
+ GPU_BACKEND_FORCED_CPU=false GPU_COUNT=0 GPU_BACKEND=cpu DRY_RUN=false
+ NATIVE_LLM_BASE_URL="$1"
+ NATIVE_LLM_GPU_NAME="$2"
+ eval "$boot_block"
+ printf '%s' "$called"
+)
+[[ "$(boot http://localhost:8080 "$GPU")" == no ]] || fail "the driver repair ran for a GPU the Windows server owns"
+[[ "$(boot '' '')" == yes ]] || fail "a host without a GPU still gets the driver repair"
+[[ "$(boot http://localhost:8080 '')" == yes ]] || fail "a native route without the Windows GPU name still gets the driver repair"
+pass "phase 02 runs no NVIDIA driver repair for a GPU a Windows model server owns"
+
+echo "native LLM GPU owner: all checks passed"