Repository navigation
fix(studio): propagate Ollama CUDA runtime to llama-server on Linux - #7563
Imagineer99 wants to merge 13 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f848733f90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acf6ae97be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d2b3a35ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Confirmed the gap: the installer counts /usr/local/lib/ollama/cuda_v* in prebuilt_core.py when picking the runtime line, but _llama_server_env_for_binary never puts that dir back on LD_LIBRARY_PATH. The branch has conflicts now, so could you rebase and I will get this reviewed. |
|
Still confirmed against main, where the Linux branch of _llama_server_env_for_binary ends at the LD_LIBRARY_PATH join without the Ollama cuda_v* dir; the branch is still showing conflicts, so could you rebase and I will get this reviewed. |
|
Live Studio A/B — verified from the spawned Head
Ordering matches the intent: the Ollama dir is appended last, so it rescues without displacing the working runtime. Caveat, for honesty: this host has no |
The Linux/WSL prebuilt installer discovers a CUDA runtime under /usr/local/lib/ollama/cuda_v* and will select a CUDA runtime line from it, but that directory is private to Ollama and is not on the dynamic linker's search path. A prebuilt whose only libcudart/libcublas copy lives there could not load its CUDA backend and silently fell back to CPU. The launchers now read the build's install marker and put the matching Ollama CUDA directory last on the child loader path, so it only rescues hosts with no other copy and never displaces the runtime that qualified the build. The whisper-server sidecar does the same, including slim bundles whose CUDA module is hardlinked from a paired llama.cpp install. Rebuilt from unslothai#7563 by Imagineer99, adapted onto current main.
The Linux/WSL prebuilt installer discovers a CUDA runtime under /usr/local/lib/ollama/cuda_v* and will select a CUDA runtime line from it, but that directory is private to Ollama and is not on the dynamic linker's search path. A prebuilt whose only libcudart/libcublas copy lives there could not load its CUDA backend and silently fell back to CPU. The launchers now read the build's install marker and put the matching Ollama CUDA directory last on the child loader path, so it only rescues hosts with no other copy and never displaces the runtime that qualified the build. The whisper-server sidecar does the same, including slim bundles whose CUDA module is hardlinked from a paired llama.cpp install. Rebuilt from unslothai#7563 by Imagineer99, adapted onto current main.
The Linux/WSL prebuilt installer discovers a CUDA runtime under /usr/local/lib/ollama/cuda_v* and will select a CUDA runtime line from it, but that directory is private to Ollama and is not on the dynamic linker's search path. A prebuilt whose only libcudart/libcublas copy lives there could not load its CUDA backend and silently fell back to CPU. The launchers now read the build's install marker and put the matching Ollama CUDA directory last on the child loader path, so it only rescues hosts with no other copy and never displaces the runtime that qualified the build. The whisper-server sidecar does the same, including slim bundles whose CUDA module is hardlinked from a paired llama.cpp install. Rebuilt from unslothai/unsloth#7563 by Imagineer99, adapted onto current main.
…t for #7563) (#11666) * fix(studio): propagate Ollama CUDA runtime to llama-server The Linux/WSL prebuilt installer discovers a CUDA runtime under /usr/local/lib/ollama/cuda_v* and will select a CUDA runtime line from it, but that directory is private to Ollama and is not on the dynamic linker's search path. A prebuilt whose only libcudart/libcublas copy lives there could not load its CUDA backend and silently fell back to CPU. The launchers now read the build's install marker and put the matching Ollama CUDA directory last on the child loader path, so it only rescues hosts with no other copy and never displaces the runtime that qualified the build. The whisper-server sidecar does the same, including slim bundles whose CUDA module is hardlinked from a paired llama.cpp install. Rebuilt from #7563 by Imagineer99, adapted onto current main. * fix(studio): never let the Ollama runtime displace a loader-resolved CUDA The vendored dir joins LD_LIBRARY_PATH, which precedes the loader's cache and its default dirs however late the entry sits, so appending it last was not enough: where ldconfig already answers libcudart/libcublas for that major, the private copy would still take precedence over the runtime that qualified the build. Yield the dir only while the loader cannot find both, falling back to the default dirs when no ldconfig can be read. The rescue direction is unchanged: with neither the cache nor the defaults providing the pair, the dir is still added. * fix(studio): count the multiarch dirs when ldconfig cannot be read The no-ldconfig fallback probed only the generic loader defaults, but Debian and Ubuntu glibc searches the architecture-specific /lib/<triple> and /usr/lib/<triple> built in -- `ld.so --list-diagnostics` lists them ahead of /lib and /usr/lib -- and the installer counts them too. A distro CUDA runtime sitting in one of those was therefore reported missing, the Ollama dir joined LD_LIBRARY_PATH, and it displaced that runtime despite the loader probe. Discover the dirs by glob rather than by machine name, so a multilib host, a second architecture, or a container holding only one of the pair is covered. The pair of arms pins it: the new discovery rule, and the real list checked against the interpreter's own MULTIARCH triple, which is what the previous draft asserted with a condition that could not hold. * fix(studio): handle loader cache ABI and symlink markers * fix(studio): restore cache probe dependency * fix(studio): ignore stale CUDA cache entries * fix(studio): handle CUDA loader edge cases * fix(studio): normalize loader cache ABI labels * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): reject unreadable loader defaults * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): check loader cache without ldconfig * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): require CUDA runtime soname links * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): probe loader after cache query failure * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Trim comments in vendored CUDA runtime rescue * Guard os.geteuid in vendored CUDA runtime tests for Windows collection * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: imagineer99 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
|
Closing this since the replacement #11666 has merged and the Ollama runtime fix is now on main. Thanks for carrying it across! |
…t for unslothai#7563) (unslothai#11666) * fix(studio): propagate Ollama CUDA runtime to llama-server The Linux/WSL prebuilt installer discovers a CUDA runtime under /usr/local/lib/ollama/cuda_v* and will select a CUDA runtime line from it, but that directory is private to Ollama and is not on the dynamic linker's search path. A prebuilt whose only libcudart/libcublas copy lives there could not load its CUDA backend and silently fell back to CPU. The launchers now read the build's install marker and put the matching Ollama CUDA directory last on the child loader path, so it only rescues hosts with no other copy and never displaces the runtime that qualified the build. The whisper-server sidecar does the same, including slim bundles whose CUDA module is hardlinked from a paired llama.cpp install. Rebuilt from unslothai#7563 by Imagineer99, adapted onto current main. * fix(studio): never let the Ollama runtime displace a loader-resolved CUDA The vendored dir joins LD_LIBRARY_PATH, which precedes the loader's cache and its default dirs however late the entry sits, so appending it last was not enough: where ldconfig already answers libcudart/libcublas for that major, the private copy would still take precedence over the runtime that qualified the build. Yield the dir only while the loader cannot find both, falling back to the default dirs when no ldconfig can be read. The rescue direction is unchanged: with neither the cache nor the defaults providing the pair, the dir is still added. * fix(studio): count the multiarch dirs when ldconfig cannot be read The no-ldconfig fallback probed only the generic loader defaults, but Debian and Ubuntu glibc searches the architecture-specific /lib/<triple> and /usr/lib/<triple> built in -- `ld.so --list-diagnostics` lists them ahead of /lib and /usr/lib -- and the installer counts them too. A distro CUDA runtime sitting in one of those was therefore reported missing, the Ollama dir joined LD_LIBRARY_PATH, and it displaced that runtime despite the loader probe. Discover the dirs by glob rather than by machine name, so a multilib host, a second architecture, or a container holding only one of the pair is covered. The pair of arms pins it: the new discovery rule, and the real list checked against the interpreter's own MULTIARCH triple, which is what the previous draft asserted with a condition that could not hold. * fix(studio): handle loader cache ABI and symlink markers * fix(studio): restore cache probe dependency * fix(studio): ignore stale CUDA cache entries * fix(studio): handle CUDA loader edge cases * fix(studio): normalize loader cache ABI labels * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): reject unreadable loader defaults * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): check loader cache without ldconfig * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): require CUDA runtime soname links * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(studio): probe loader after cache query failure * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Trim comments in vendored CUDA runtime rescue * Guard os.geteuid in vendored CUDA runtime tests for Windows collection * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: imagineer99 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
Summary
llama-serverenvironmentruntime_lineexactly and require both cuBLAS and CUDA runtime libraries before adding a directoryWhy
The Linux/WSL installer can select a CUDA prebuilt after discovering libraries under
/usr/local/lib/ollama/cuda_v*. Those private Ollama directories are not normally visible to the dynamic linker, and the launcher did not carry the selected directory intoLD_LIBRARY_PATH. The CUDA backend could therefore fail to load and silently fall back to CPU after an otherwise successful install.This is Linux-only and leaves the Windows and macOS launcher paths unchanged.
Validation
278 passed—studio/backend/tests/test_llama_cpp_mtp_detection.py346 passed—unsloth_cli/tests/test_start.py389 passed— OpenAI tool-passthrough and Anthropic message suites--no-torchWSL install plus Qwen3.5-9B action tests completed through Pi, Claude, OpenCode, and Codex without the prior CPU-fallback timeouts