From 6234161462c0b0cfdb5e14204c56bd85d6af53f7 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 13 Oct 2026 18:10:07 +0200 Subject: [PATCH] LocalAI: pin the CPU backends when the container has no GPU runtime (#17909) LocalAI resolves meta backends from the GPU vendor it reads out of sysfs, which is the host's card even with no driver installed in the container, so llama-cpp became cuda12-llama-cpp and never started (#17908). Force the default capability unless a CUDA, ROCm or Level Zero runtime is present; update adds the pin to existing installs. --- ct/localai.sh | 9 +++++++++ install/localai-install.sh | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/ct/localai.sh b/ct/localai.sh index 20ecfabaf..2bb39f514 100644 --- a/ct/localai.sh +++ b/ct/localai.sh @@ -37,6 +37,15 @@ function update_script() { exit fi + # Older installs have no CPU pin; on a host with a GPU but no driver in the + # container every model then ends in "backend not found". + if ! grep -q '^LOCALAI_FORCE_META_BACKEND_CAPABILITY=' /opt/localai.env 2>/dev/null && + ! ldconfig -p 2>/dev/null | grep -qE 'libcuda[.]so|libamdhip64[.]so|libze_intel_gpu[.]so|libze_loader[.]so'; then + echo "LOCALAI_FORCE_META_BACKEND_CAPABILITY=default" >>/opt/localai.env + systemctl restart localai + msg_ok "Pinned LocalAI to the CPU backends (no GPU runtime in the container)" + fi + if check_for_gh_release "localai" "mudler/LocalAI"; then msg_info "Stopping Service" systemctl stop localai diff --git a/install/localai-install.sh b/install/localai-install.sh index 2171e2c1e..c5c1ecd53 100644 --- a/install/localai-install.sh +++ b/install/localai-install.sh @@ -39,6 +39,12 @@ LOCALAI_MODELS_PATH=/opt/localai_data/models LOCALAI_BACKENDS_PATH=/opt/localai_data/backends LOCALAI_LOG_LEVEL=info EOF +# LocalAI picks the backend variant from the GPU it sees in sysfs, which is the +# host's card even when no driver was installed in here, and a CUDA/ROCm/SYCL +# backend then never starts. Pin the CPU variants unless a runtime is present. +if ! ldconfig -p 2>/dev/null | grep -qE 'libcuda[.]so|libamdhip64[.]so|libze_intel_gpu[.]so|libze_loader[.]so'; then + echo "LOCALAI_FORCE_META_BACKEND_CAPABILITY=default" >>/opt/localai.env +fi # LocalAI refuses to start on a wildcard bind with nothing to identify callers, # and binding the wildcard is what makes the container reachable at all. if [[ "$var_auth" == "yes" ]]; then