The project's README from github.com/leejet/stable-diffusion.cpp. As one markdown file: README.md.
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.
--embd-dir and <embedding:...> tags.ckpt or .pth or .pt).safetensors).gguf).gguf or .safetensors--rng cuda, default, consistent with the stable-diffusion-webui GPU RNG--rng cpu, consistent with the comfyui RNGThe executable examples below run from the build directory (cd build from
the repository root). Windows examples use the Visual Studio Release path;
adjust the executable path for other build configurations or extracted archives.
Model files stay under the repository's models/ directory.
Choose a model from the model guides and download its
weights and required components. For a simple example, save Stable Diffusion 1.5
under models/checkpoints/:
Windows (PowerShell)
New-Item -ItemType Directory -Force ..\models\checkpoints | Out-Null
curl.exe -L -o ..\models\checkpoints\v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
Linux/macOS
mkdir -p ../models/checkpoints
curl -L -o ../models/checkpoints/v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
Start the server:
Windows (PowerShell)
.\bin\Release\sd-server.exe --model-dir ..\models
Linux/macOS
./bin/sd-server --model-dir ../models
Open http://127.0.0.1:1234/, choose SD 1.x in Recipe, select the checkpoint, and click Load models. Enter a prompt and click Generate. See the Web UI guide for the full workflow.
Generate an image with one command:
Windows (PowerShell)
.\bin\Release\sd-cli.exe -m ..\models\checkpoints\v1-5-pruned-emaonly.safetensors -p "a lovely cat"
Linux/macOS
./bin/sd-cli -m ../models/checkpoints/v1-5-pruned-emaonly.safetensors -p "a lovely cat"
Run .\bin\Release\sd-cli.exe --help on Windows or ./bin/sd-cli --help on
Linux/macOS for all command-line options. See the
CLI guide for additional usage notes.
If you want to improve performance or reduce VRAM/RAM usage, please refer to performance guide. For runtime and parameter backend placement, see the backend selection guide.
Browse the documentation index or jump to a topic:
Thank you to all the people who have already contributed to stable-diffusion.cpp!