* build: fix missing commit sha in macOS and Ubuntu build zip name The build workflows for macOS and Ubuntu incorrectly check for the "main" branch instead of "master" when retrieving the commit hash for naming the build artifacts. * build: correct Vulkan SDK installation condition in build workflow * build: Enable Windows ROCm(HIP) build release Refer to the build workflow of llama.cpp to add a Windows ROCm (HIP) build release to the workflow. Since there are many differences between the HIP build and other builds, this commit add a separate "windows-latest-cmake-hip" job, instead of enabling the ROCm matrix entry in the existing Windows build job. Main differences include: - Install ROCm SDK from AMD official installer. - Add a cache step for ROCm installation and a ccache step for build processing, since the HIP build takes much longer time than other builds. - Include the ROCm/HIP artifact in the release assets.
stable-diffusion.cpp
Diffusion model(SD,Flux,Wan,...) inference in pure C/C++
Note that this project is under active development.
API and command-line option may change frequently.
🔥Important News
-
2025/10/13 🚀 stable-diffusion.cpp now supports Qwen-Image-Edit / Qwen-Image-Edit 2509
👉 Details: PR #877 -
2025/10/12 🚀 stable-diffusion.cpp now supports Qwen-Image
👉 Details: PR #851 -
2025/09/14 🚀 stable-diffusion.cpp now supports Wan2.1 Vace
👉 Details: PR #819 -
2025/09/06 🚀 stable-diffusion.cpp now supports Wan2.1 / Wan2.2
👉 Details: PR #778
Features
- Plain C/C++ implementation based on ggml, working in the same way as llama.cpp
- Super lightweight and without external dependencies
- Supported models
- Image Models
- Image Edit Models
- Video Models
- PhotoMaker support.
- Control Net support with SD 1.5
- LoRA support, same as stable-diffusion-webui
- Latent Consistency Models support (LCM/LCM-LoRA)
- Faster and memory efficient latent decoding with TAESD
- Upscale images generated with ESRGAN
- Supported backends
- CPU (AVX, AVX2 and AVX512 support for x86 architectures)
- CUDA
- Vulkan
- Metal
- OpenCL
- SYCL
- Supported weight formats
- Pytorch checkpoint (
.ckptor.pth) - Safetensors (
./safetensors) - GGUF (
.gguf)
- Pytorch checkpoint (
- Supported platforms
- Linux
- Mac OS
- Windows
- Android (via Termux, Local Diffusion)
- Flash Attention for memory usage optimization
- Negative prompt
- stable-diffusion-webui style tokenizer (not all the features, only token weighting for now)
- VAE tiling processing for reduce memory usage
- Sampling method
Euler AEulerHeunDPM2DPM++ 2MDPM++ 2M v2DPM++ 2S aLCM
- Cross-platform reproducibility (
--rng cuda, consistent with thestable-diffusion-webui GPU RNG) - Embedds generation parameters into png output as webui-compatible text string
Quick Start
Get the sd executable
- Download pre-built binaries from the releases page
- Or build from source by following the build guide
Download model weights
-
download weights(.ckpt or .safetensors or .gguf). For example
- Stable Diffusion v1.5 from https://huggingface.co/runwayml/stable-diffusion-v1-5
curl -L -O https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
Generate an image with just one command
./bin/sd -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
For detailed command-line arguments, check out cli doc.
Performance
If you want to improve performance or reduce VRAM/RAM usage, please refer to performance guide.
More Guides
- SD1.x/SD2.x/SDXL
- SD3/SD3.5
- Flux-dev/Flux-schnell
- FLUX.1-Kontext-dev
- Chroma
- 🔥Qwen Image
- 🔥Qwen Image Edit/Qwen Image Edit 2509
- 🔥Wan2.1/Wan2.2
- LoRA
- LCM/LCM-LoRA
- Using PhotoMaker to personalize image generation
- Using ESRGAN to upscale results
- Using TAESD to faster decoding
- Docker
- Quantization and GGUF
Bindings
These projects wrap stable-diffusion.cpp for easier use in other languages/frameworks.
- Golang (non-cgo): seasonjs/stable-diffusion
- Golang (cgo): Binozo/GoStableDiffusion
- C#: DarthAffe/StableDiffusion.NET
- Python: william-murray1204/stable-diffusion-cpp-python
- Rust: newfla/diffusion-rs
- Flutter/Dart: rmatif/Local-Diffusion
UIs
These projects use stable-diffusion.cpp as a backend for their image generation.
- Jellybox
- Stable Diffusion GUI
- Stable Diffusion CLI-GUI
- Local Diffusion
- sd.cpp-webui
- LocalAI
- Neural-Pixel
- KoboldCpp
Contributors
Thank you to all the people who have already contributed to stable-diffusion.cpp!
