stable-diffusion.cpp/docs/docker.md
Claude 2e354710ce
Merge upstream/master (leejet/stable-diffusion.cpp b13a482) into fix_to_claude
Brings in the 20 upstream commits since 2988060 (2026-10-11): per-module
automatic flash attention (#2132), automatic direct convolution (#2134,
#2141), reclaim before trusting wrapped Vulkan iGPU memory estimates
(#2124), UTF-8 file paths on Windows (#2144, #2145), FP8 CPU crash fix
(#2140), the ggml sync to dc99877 (#2147), FLUX.3 Klein, MOSS-Image, the
MoSR upscaler, MiniMax-H3 LoRAs, Qwen Image 2.1 Turbo preset, ROCm and
MUSA Dockerfiles, documentation.

Conflicts resolved, keeping both sides:

- include/stable-diffusion.h: upstream's flash_attn_mode and
  conv_direct_mode stay right after conditioning_cache_size, so the
  layout up to there is still upstream's; memory_guard,
  disable_backend_fallback and multi_gpu follow.
- src/core/ggml_extend_backend.cpp: upstream's new cuda_compiled_arch()
  keeps asking the compute capability through sd::cuda_driver (the driver
  is looked up at run time, so the engine starts where there is no NVIDIA
  driver), not through <cuda.h>; the HIP include from upstream is kept.
- src/model_manager.cpp: the CPU memory guard and upstream's
  requires_reclamation rule are both applied: a Vulkan iGPU estimate that
  wrapped is reclaimed before it is trusted, and the guard still decides
  for the CPU backend.
- src/model_loader.cpp: includes of both sides; load_worker keeps the
  file handle pool and the open retry.
- examples/server/runtime.cpp: --degradation-cooldown check and
  upstream's u8path for the --serve-html-path check.
- docs/backend.md: the "Several GPUs" section and upstream's "Direct
  convolution" and "Flash attention" sections.

The ggml submodule moves from d25b121 to dc99877 (upstream's pin).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
2026-10-18 19:51:51 +02:00

3.3 KiB

Docker

The container images are built from this repository by the CI (.github/workflows/build.yml) and published to the GitHub Container Registry as ghcr.io/filve/diffusione-in-tempo-reale, so they always contain the code of this fork. Every push to master updates these tags:

Tag Backend Platform Notes
master-cpu CPU only linux/amd64 no GPU needed
master-cuda CUDA 12 linux/amd64 NVIDIA GPUs; start it with --gpus all (needs the NVIDIA Container Toolkit)
master-vulkan Vulkan linux/amd64 AMD and Intel GPUs through Mesa; pass the GPU with --device /dev/dri
master-musa MUSA linux/amd64 Moore Threads GPUs
master-sycl SYCL linux/amd64 Intel GPUs
master-cuda-spark CUDA 13 linux/arm64 NVIDIA DGX Spark

The examples below use the CPU image; swap the tag for the one that matches your hardware.

Run CLI

docker run --rm -v /path/to/models:/models -v /path/to/output/:/output ghcr.io/filve/diffusione-in-tempo-reale:master-cpu [args...]
# For example
# docker run --rm -v ./models:/models -v ./build:/output ghcr.io/filve/diffusione-in-tempo-reale:master-cpu -m /models/sd-v1-4.ckpt -p "a lovely cat" -v -o /output/output.png

Check that an NVIDIA GPU is visible to the container before generating:

docker run --rm --gpus all ghcr.io/filve/diffusione-in-tempo-reale:master-cuda --list-devices

Run server

docker run --rm --init -v /path/to/models:/models -v /path/to/output/:/output -p "1234:1234" --entrypoint "/sd-server" ghcr.io/filve/diffusione-in-tempo-reale:master-cpu [args...]
# For example
# docker run --rm --init -v ./models:/models -v ./build:/output -p "1234:1234" --entrypoint "/sd-server" ghcr.io/filve/diffusione-in-tempo-reale:master-cpu -m /models/sd-v1-4.ckpt -p "a lovely cat" -v -o /output/output.png

Building using Docker

docker build -f docker/Dockerfile -t sd .

Building variants using Docker

Vulkan:

docker build -f docker/Dockerfile.vulkan -t sd .

ROCm (AMD GPU):

Defining one or multiple targets with --build-arg AMDGPU_TARGETS is strongly recommended. Building the image will otherwise likely fail or build for a target that does not fit your hardware.

# Build for one target
docker build -f docker/Dockerfile.rocm --build-arg "AMDGPU_TARGETS=gfx1100" -t sd .
# Build for multiple targets
docker build -f docker/Dockerfile.rocm --build-arg "AMDGPU_TARGETS=gfx1030;gfx1100" -t sd .

Run locally built image's CLI

docker run --rm -v /path/to/models:/models -v /path/to/output/:/output sd [args...]
# For example
# docker run --rm -v ./models:/models -v ./build:/output sd -m /models/sd-v1-4.ckpt -p "a lovely cat" -v -o /output/output.png

ROCm (AMD GPU)

The user that executes this command needs to be in the video group and have read and write access to /dev/dri and /dev/kfd.

--device and --group-add allow the container access to the GPU.

docker run --rm --device=/dev/dri --device=/dev/kfd --group-add video \
  -v /path/to/models:/models -v /path/to/output/:/output \
  sd [args...]
# For example
# docker run --rm --device=/dev/dri --device=/dev/kfd --group-add video \
#   -v ./models:/models -v ./build:/output \
#   sd -m /models/sd-v1-4.ckpt -v -o /output/output.png \
#   -p "a lovely cat"