Skip to content

studio/setup.sh: validate source-built llama.cpp and guard empty CUDA arch detection #5854

Closed

Description

@danielhanchen

Context

PR #5826 hardened studio/setup.sh for fresh CUDA toolkits (the -allow-unsupported-compiler flag, plus a generalized CUDA/ROCm to CPU fallback). While validating that change I hit two related gaps that the prebuilt path already handles but the source-build path does not. Filing as a follow-up.

1. Empty CUDA arch detection produces a PTX-only build that can fail at runtime

The source build sets -DCMAKE_CUDA_ARCHITECTURES from nvidia-smi --query-gpu=compute_cap. If that query returns nothing (the build log then reads building (CUDA) rather than building (CUDA, sm_120)), llama.cpp builds for its default arch list and ships PTX only. On a driver older than the toolkit, loading that binary fails at runtime with:

CUDA error: the provided PTX was compiled with an unsupported toolchain.

The build itself succeeds, so neither the build-time check nor the new CPU fallback catches it, and the user ends up with a llama-server that crashes on first use.

Repro: build llama.cpp with the CUDA 13.3 toolkit and no -DCMAKE_CUDA_ARCHITECTURES, then run it on a driver that only advertises CUDA 13.0.

Suggested: if the detected arch list comes back empty, either skip CUDA and build CPU, or stop with a clear message, rather than silently producing a PTX-only build.

2. The source-build path has no post-build validation

install_llama_prebuilt.py validates the prebuilt before accepting it (it runs llama-server --n-gpu-layers 1 against a tiny model). The source-build path has no equivalent: once it links llama-server it is accepted, even if the binary cannot actually run on this GPU and driver (see 1).

Suggested: after a source GPU build, run the same lightweight GPU smoke test; if it fails, reuse the new _gpu_fallback_label path to retry a CPU build so the user still ends up with a working server.

Why it matters

A user whose prebuilt validation fails will fall through to a source build (this is one of the few real ways to reach the source path). If that source build then produces a non-running binary, the fall-through has not actually helped. Closing this loop makes the source-build fallback as trustworthy as the prebuilt path.

Refs #5826.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions