Skip to main content

Module sd_provision

Module sd_provision 

Source
Expand description

Auto-provision the stable-diffusion.cpp sd-cli binary.

The sdcpp engine subprocess-invokes sd-cli per image job. Model weights already download on demand (see download); this module fills the remaining gap so a fresh worker is turnkey: on the first image job, if no sd-cli is resolvable, we download the platform’s prebuilt stable-diffusion.cpp Vulkan build (universal across NVIDIA / AMD / Intel, ~37 MB) and extract it into <models_root>/bin/, the PATH-free slot the resolver already prefers.

The upstream release is pinned for reproducibility. Overrides:

  • STUDIO_WORKER_SDCPP_RELEASE — a master-<n>-<sha> tag to fetch instead of the pinned default.
  • STUDIO_WORKER_SDCPP_URL — a full zip URL (skips tag/asset resolution entirely; used by tests and air-gapped mirrors).

Windows resolves the sibling stable-diffusion.dll automatically (same dir as the .exe). Linux / macOS need the loader pointed at the binary’s dir — see library_path_env, applied per job.

Functions§

binary_name
Platform binary name for stable-diffusion.cpp’s CLI.
library_path_env
If a stable-diffusion shared library sits next to sd_cli, return the (env-var, dir) the per-job Command must set so the dynamic linker finds it. Returns None on Windows (sibling DLLs resolve automatically) and when no sibling library is present (e.g. an operator’s wrapper-script install manages its own load path).
provision
Ensure sd-cli is installed under <models_root>/bin/, downloading and extracting the platform’s stable-diffusion.cpp build when it’s missing. Returns the resolved binary path. Idempotent: a binary already present short-circuits the download.
vulkan_runtime_status
Live preflight: probes the real loader. Excluded from coverage for the same host-dependent reason as [vulkan_loader_loads]; the decision logic is covered via [vulkan_runtime_status_with].