Skip to content

Studio: reuse llama.cpp's CUDA wheels for audio.cpp on Windows chat-only installs - #18275

Merged
shimmyshimmer merged 2 commits into
mainfrom
studio-audiocpp-windows-reuse-cuda-wheels
Nov 18, 2026
Merged

shimmyshimmer merged 2 commits into
mainfrom
studio-audiocpp-windows-reuse-cuda-wheels

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Chat-only (no torch) Windows x64 installs with an NVIDIA GPU download cuBLAS twice: once for llama.cpp, once for audio.cpp.

Why

Since #17463 the llama.cpp step installs NVIDIA's nvidia-cuda-runtime and nvidia-cublas wheels into the Studio env on chat-only installs (about 410 MB for CUDA 13). The audio.cpp Windows CUDA bundle then downloads its own cudart-windows-x64-cuda13.zip (589 MB; 724 MB for CUDA 12), because torch_provides_cuda_runtime only looks in torch\lib. That archive holds cudart64_13.dll, cublas64_13.dll, cublasLt64_13.dll (458 MiB) and cufft64_12.dll (271 MiB), so everything but cuFFT is already on disk.

Change

studio/install_audio_cpp_prebuilt.py, Windows x64 only, when there is no torch and the bundle would download its cudart archive:

  • If the env's nvidia\* wheel dirs (the ones audio_cpp_server already puts on PATH) hold cudart64_N, cublas64_N and cublasLt64_N for the bundle's CUDA line, install only nvidia-cufft (nvidia-cufft-cu12 for CUDA 12), check again, and skip the archive.
  • Otherwise download the archive exactly as today: cuFFT failing to install, wheels for another CUDA line, Windows ARM64, or a torch install. So it never downloads more than it does now.
  • A kept install without the archive is intact while those DLLs are still in the env (_cuda_runtime_satisfied), so a later setup reinstalls if they go away. Installs that already carry the archive are untouched.

Saves about 395 MB per chat-only Windows CUDA 13 install and about 500 MB per CUDA 12 install. Linux, macOS, AMD, Windows ARM64 and installs with torch take the same path as before. On Windows audiocpp_server.exe imports cufft64_12.dll and ggml-cuda.dll imports cublas64_13.dll, so both have to resolve from the wheel dirs, which the run below checks.

Tests

windows-latest (no GPU), each arm a torch-free venv holding llama.cpp's chat-only CUDA 13 wheels, bundle audio-v0.9.5-unsloth.1-bin-windows-x64-cuda13.zip:

main this PR
CUDA runtime downloads cudart-windows-x64-cuda13.zip, 4 DLLs beside the server installs nvidia-cufft 12.5.0.14 (+ nvidia-nvjitlink), no DLLs beside the server
audiocpp_server.exe --version with the Studio runtime dirs on PATH exit 0, backends: cpu,cuda exit 0, backends: cpu,cuda
ggml-cuda.dll loads yes yes, from the wheel dirs
same server without the wheel dirs n/a exit 0xC0000135 (DLL not found)
installer run again n/a already matches, nothing installed

tests/studio/install/test_install_audio_cpp_prebuilt_logic.py: 255 passed (14 new). With only the two functional hunks reverted (helpers kept), the install-skips-the-archive and intact-install tests fail.

Not covered here: a real Windows NVIDIA GPU running audio.cpp on CUDA (no runner has one).

…els for audio.cpp instead of its cudart archive
@danielhanchen danielhanchen self-assigned this Nov 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T10:42:12.369239Z e634c87 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 652776224f

ℹ️ 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".

danielhanchen added a commit that referenced this pull request Nov 18, 2026
## Name the encoding on the sd.cpp nvidia-smi probe


`studio/backend/tests/test_text_io_encoding.py::test_text_io_names_its_encoding[sd_cpp_backend.py]`
fails on `main` since #18210. On staging it shows up as `(Python 3.13,
rest)` failing on unrelated PRs, for example #17694 and #18275:

```
E       sd_cpp_backend.py:3146: subprocess(text = True) without encoding
E   assert not ['sd_cpp_backend.py:3146: subprocess(text = True) without encoding']
```

### Cause

#18210 added `_sole_nvidia_card_mib()`, which reads nvidia-smi's output
with `subprocess.run(..., text = True)` but no `encoding`. That falls
back to `locale.getencoding()`, the ANSI codepage on Windows, which is
exactly what this lint exists to catch.

The other three `subprocess.run(text = True)` calls in
`sd_cpp_backend.py` already pass `encoding = "utf-8", errors =
"replace"`. The new probe just missed it.

### Fix

The probe now passes `encoding = "utf-8", errors = "replace"` like its
neighbours. nvidia-smi's CSV output is ASCII, so what the probe parses
does not change. A stray byte can no longer raise inside the probe.

### Verification

- `tests/test_text_io_encoding.py`: fails on `main` on this line and
passes with this change.
- `tests/test_sd_cpp_backend.py` also passes: 1289 passed across both
files.
- ruff is clean.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: e634c87afb

ℹ️ 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".

@shimmyshimmer
shimmyshimmer merged commit 6e434a6 into main Nov 18, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-audiocpp-windows-reuse-cuda-wheels branch November 18, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants