Skip to content

fix(stt): register pip CUDA DLL dirs so Windows GPU inference works - #110679

Open
zwn-ai wants to merge 1 commit into
NousResearch:mainfrom
zwn-ai:fix/windows-cublas-dll-registration
Open

zwn-ai wants to merge 1 commit into
NousResearch:mainfrom
zwn-ai:fix/windows-cublas-dll-registration

Conversation

@zwn-ai

@zwn-ai zwn-ai commented Sep 14, 2026

Copy link
Copy Markdown

Summary

On Windows, faster-whisper pulls in the nvidia-cublas-cu12 wheel (and friends), whose cublas64_12.dll / cublasLt64_12.dll land under site-packages/nvidia/cublas/bin — a directory that is not on PATH.

ctranslate2 loads cuBLAS lazily via LoadLibrary, so with the directory unregistered the CUDA backend fails — frequently only at the first transcribe() call, not at model load. Hermes then takes the existing CPU (int8) fallback and runs an order of magnitude slower, with no error surfaced to the user.

Measured on an RTX 4060 Laptop, 8 s Chinese clip, small / float16:

before after
cold ~48 s, wrong-language output (silent CPU fallback) ~2.2 s, correct output
warm ~0.4 s

Change

_register_windows_cuda_dll_dirs() — called from _load_local_whisper_model() before the model is created — registers every site-packages/nvidia/<pkg>/bin it finds (cublas, cudnn, cuda_nvrtc, cufft, curand) with both os.add_dll_directory and PATH, covering the different loader flags ctranslate2 may use.

The os.add_dll_directory handles are retained for the life of the process, because the directory is unregistered again once the return value is garbage-collected.

No-op on non-Windows hosts; idempotent.

Test Plan

  • ruff check tools/transcription_tools.py tests/tools/test_transcription_tools.py — clean
  • scripts/run_tests.sh on the STT test set — 98 passed, 0 failed
  • New tests cover: no-op off Windows, directory discovery, PATH augmentation, handle retention, idempotency
  • Verified on a real Windows host: with the patch applied and no cuBLAS on PATH, the CUDA backend loads (2 handles registered) and transcription runs ~2.2 s vs ~48 s before

faster-whisper pulls in the nvidia-cublas-cu12 wheel on Windows, whose
cublas64_12.dll lands under site-packages/nvidia/cublas/bin — not on PATH.
ctranslate2 loads cuBLAS lazily, so the CUDA backend fails and Hermes
silently falls back to CPU (int8); on an RTX 4060 that turned an 8 s clip
into ~48 s of wrong-language output with no error surfaced.

Register every site-packages/nvidia/<pkg>/bin (cublas, cudnn, cuda_nvrtc,
cufft, curand) via os.add_dll_directory and PATH before the model loads.
Handles are kept alive (add_dll_directory unregisters on GC). No-op off
Windows; idempotent. After: ~2.2 s cold / 0.4 s warm, correct output.

Tests: no-op off Windows, directory discovery, PATH augmentation, handle
retention, idempotency.
@zwn-ai
zwn-ai force-pushed the fix/windows-cublas-dll-registration branch from 8e923b8 to 96cc3ad Compare September 14, 2026 07:50
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/tts Text-to-speech and transcription platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Sep 14, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Competing fix for #103793 alongside #75554 (earlier, PATH-only) and #103848 (mid-transcribe CPU retry). This PR additionally uses os.add_dll_directory and retains the handles; maintainers should pick one approach.

@kvnloo

kvnloo commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Comment assumes head 96cc3adf4efb05c8e457f584b9f7b334b151fcff; void if moved.

KEEP — Windows pip CUDA DLL registration (closes #103793 registration axis)

CHECK

One-click close / ordering

Landing-evidence

  • When merged, please reply with the merge commit SHA on main (not “completed”).

@kvnloo

kvnloo commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Comment assumes head 96cc3adf4efb05c8e457f584b9f7b334b151fcff; void if moved.

KEEP — Windows pip CUDA DLL registration (closes #103793 registration axis)

CHECK

One-click close / ordering

Landing-evidence

  • When merged, please reply with the merge commit SHA on main (not “completed”).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants