Repository navigation
feat(runtime): warn when a CPU-only build runs on an NVIDIA host (#326) - #372
Merged
Merged
Conversation
A plain `cargo build --release` on Linux omits the `cuda` feature and produces a CPU-only binary that silently runs MLX on the host CPU at a fraction of GPU throughput (single-digit tok/s on GB10). Call this out in the README build section and next to the CUDA build command in installation.md so the `--features cuda` requirement is hard to miss on an NVIDIA host.
A default `cargo build --release` on Linux omits the `cuda` feature and produces a CPU-only binary. It still loads and generates, but silently runs MLX on the host CPU at single-digit tok/s, and "Runtime device: CPU" is easy to miss. This bit a benchmarking session on GB10 (#326). At startup, when the user wanted the GPU but a CPU-only binary fell back to CPU on a host that has an NVIDIA GPU, print a loud one-line warning pointing at the `--features cuda` rebuild (or `cargo cuda`). Detection uses the NVIDIA device nodes (/dev/nvidiactl, /proc/driver/nvidia/version), which the kernel driver exposes without linking CUDA, so a CPU-only build can still tell it is on an NVIDIA host. An explicit MLXCEL_DEVICE=cpu suppresses the warning, and a cuda-capable build that fell back to CPU is a genuine no-GPU host, not the footgun. The decision is a pure function with a unit test. Also add a `.cargo/config.toml` `cargo cuda` alias for the feature-correct build, and document the footgun in the README and installation.md.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…lup#326) (lablup#372) A default `cargo build --release` on Linux omits the `cuda` feature and produces a CPU-only binary that still runs but executes MLX on the host CPU at single-digit tok/s, with only `Runtime device: CPU` as a hint. This bit a GB10 benchmarking session for lablup#326. At startup, when the user wanted the GPU but a CPU-only binary fell back to CPU on a host that has an NVIDIA GPU (detected via `/dev/nvidiactl` or `/proc/driver/nvidia/version`, which need no CUDA linkage), print a one-line warning pointing at the `--features cuda` rebuild or the new `cargo cuda` alias. An explicit `MLXCEL_DEVICE=cpu` suppresses it, and a cuda-capable build that fell back to CPU is a genuine no-GPU host, not the footgun. The decision is a pure function with a unit test. Also adds the `cargo cuda` alias in `.cargo/config.toml` and documents the footgun in the README build section and installation.md. No behavior change on a correctly built GPU binary. Follow-up to lablup#326 and lablup#357.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A default
cargo build --releaseon Linux uses the default features (surgeryonly), omitscuda, and produces a CPU-only binary. It still loads and generates, but silently runs MLX on the host CPU at single-digit tok/s, and the only hint isRuntime device: CPU. This bit a GB10 benchmarking session for #326 (0.13 tok/s before the mistake was caught) and is already flagged inmodel_tests_gb10.md.What
Three layers of prevention for the same footgun:
--features cudarebuild. Fires every time the mistake happens, regardless of how the binary was built./dev/nvidiactl,/proc/driver/nvidia/version), which the kernel driver exposes without linking CUDA, so a CPU-only build can still tell it is on an NVIDIA host.MLXCEL_DEVICE=cpusuppresses it, and acuda-capable build that fell back to CPU is a genuine no-GPU host, not the footgun.should_warn_cpu_only_on_nvidia_host) with a unit test.cargo cudaalias (.cargo/config.toml) for the feature-correct build, so the right thing is one token.installation.mdnow call out the CPU-only footgun next to the build commands.No behavior change on a correctly built GPU binary: the warning is gated to CPU-fallback-on-NVIDIA-without-cuda, and the
cuda/Metal paths never reach it.Validation
should_warn_cpu_only_on_nvidia_hostunit test (5 cases: footgun fires; cuda build, no-NVIDIA host, explicit CPU, and on-GPU all stay quiet). Passes undercargo test --release --features cuda --lib.--features cudaand default (CPU-only) configurations.Follow-up to #326 / #357 (the GB10 fused QK-norm benchmark, where this footgun first showed up).