[PR #2382] [CLOSED] setup: put the CUDA runtime DLLs (bin\x64) on the image job's search path on Windows #4015

Closed
opened 2026-11-07 15:32:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2382
Author: @hogtinbao
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix-image-libdirs


📝 Commits (1)

  • a3cbcf8 setup: put the CUDA runtime DLLs (bin\x64) on the image job's search path on Windows

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 setup.py (+2 -1)

📄 Description

Fixes #2381.

The bug

setup.py's build_image_engine recorded lib_dirs for a Windows CUDA build as <CUDA_ROOT>\bin:

lib_dirs = [str(root / "bin")] if WIN else [str(d) for d in (root / "lib64", root / "lib") if d.is_dir()]

CUDA 12 moved the runtime libraries to <CUDA_ROOT>\bin\x64; bin keeps only the tools (nvcc.exe, ptxas.exe, nvlink.exe, ...). On a CUDA 13.0.2 install:

<CUDA_ROOT>\bin\*.dll        0 files
<CUDA_ROOT>\bin\x64\*.dll   27 files   (cublas64_13.dll, cublasLt64_13.dll, cudart64_13.dll, ...)

tools/image/install.py stores that list in the run config (images.lib_dirs), and serve/images.py / serve/server.py prepend it to the child's PATH. So sd-cli.exe cannot resolve cublas64_13.dll, exits with 3221225781 (0xC0000135, STATUS_DLL_NOT_FOUND), and the API answers:

HTTP 500 {"error": {"type": "server_error", "code": "image_generation_failed",
                    "message": "sd-cli exited with code 3221225781; the end of its log:\n"}}

Anyone who installs CUDA on Windows and enables image generation hits this; nothing else in the build or the three model files is at fault.

The fix

lib_dirs = ([str(d) for d in (root / "bin" / "x64", root / "bin") if d.is_dir()] if WIN
            else [str(d) for d in (root / "lib64", root / "lib") if d.is_dir()])

bin\x64 first, bin second, so CUDA 11 (DLLs in bin), CUDA 12/13 (bin\x64), and any layout that has both are covered. The Linux branch is untouched.

Verification

  • On a real CUDA 13.0.2 root the new expression returns [<CUDA>\bin\x64, <CUDA>\bin] with cublas64_13.dll present in the first entry, where the old expression returned only <CUDA>\bin (0 DLLs in it).
  • python -m unittest tools.test_qimage → 14 tests OK; python -m unittest serve.test_images → 19 tests OK.
  • End to end on Windows 11 / RTX 5070 Ti 12 GB / CUDA 13.0.2 / Q6_K, with images.lib_dirs hand-patched the same way: POST /v1/images/generations renders 512×512 in ~21 s and 1024×1024 in ~26 s.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2382 **Author:** [@hogtinbao](https://github.com/hogtinbao) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-image-libdirs` --- ### 📝 Commits (1) - [`a3cbcf8`](https://github.com/Niko1221/Strata/commit/a3cbcf8afbc7fc8b7365da1e07b6e06786a23ba8) setup: put the CUDA runtime DLLs (bin\x64) on the image job's search path on Windows ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+2 -1) </details> ### 📄 Description Fixes #2381. ## The bug `setup.py`'s `build_image_engine` recorded `lib_dirs` for a Windows CUDA build as `<CUDA_ROOT>\bin`: ```python lib_dirs = [str(root / "bin")] if WIN else [str(d) for d in (root / "lib64", root / "lib") if d.is_dir()] ``` CUDA 12 moved the runtime libraries to `<CUDA_ROOT>\bin\x64`; `bin` keeps only the tools (`nvcc.exe`, `ptxas.exe`, `nvlink.exe`, ...). On a CUDA 13.0.2 install: ``` <CUDA_ROOT>\bin\*.dll 0 files <CUDA_ROOT>\bin\x64\*.dll 27 files (cublas64_13.dll, cublasLt64_13.dll, cudart64_13.dll, ...) ``` `tools/image/install.py` stores that list in the run config (`images.lib_dirs`), and `serve/images.py` / `serve/server.py` prepend it to the child's `PATH`. So `sd-cli.exe` cannot resolve `cublas64_13.dll`, exits with `3221225781` (`0xC0000135`, `STATUS_DLL_NOT_FOUND`), and the API answers: ``` HTTP 500 {"error": {"type": "server_error", "code": "image_generation_failed", "message": "sd-cli exited with code 3221225781; the end of its log:\n"}} ``` Anyone who installs CUDA on Windows and enables image generation hits this; nothing else in the build or the three model files is at fault. ## The fix ```python lib_dirs = ([str(d) for d in (root / "bin" / "x64", root / "bin") if d.is_dir()] if WIN else [str(d) for d in (root / "lib64", root / "lib") if d.is_dir()]) ``` `bin\x64` first, `bin` second, so CUDA 11 (DLLs in `bin`), CUDA 12/13 (`bin\x64`), and any layout that has both are covered. The Linux branch is untouched. ## Verification - On a real CUDA 13.0.2 root the new expression returns `[<CUDA>\bin\x64, <CUDA>\bin]` with `cublas64_13.dll` present in the first entry, where the old expression returned only `<CUDA>\bin` (0 DLLs in it). - `python -m unittest tools.test_qimage` → 14 tests OK; `python -m unittest serve.test_images` → 19 tests OK. - End to end on Windows 11 / RTX 5070 Ti 12 GB / CUDA 13.0.2 / `Q6_K`, with `images.lib_dirs` hand-patched the same way: `POST /v1/images/generations` renders 512×512 in ~21 s and 1024×1024 in ~26 s. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:32:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4015
No description provided.