Zyx-A / sd-webui-docker-base

🐳 Dockerfile for 🖼️ Stable Diffusion WebUI, only runtime environment & bootstrapping scripts. | SD-WebUI 的容器镜像,但仅含运行环境与安装启动脚本。

Home Page:https://hub.docker.com/r/yanwk/sd-webui-base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yet another Docker image for Stable Diffusion WebUI

GitHub Workflow Status
Concept Design

This repo is inspired by AbdBarho, with a different approach, and only supports AUTOMATIC1111.

Idea

A heavy user of SD-WebUI would probably have a lot of models, extensions, and want everything up-to-date. This Docker image is how I figured out to manage them:

Keeping the app & data in one place, and leaving the dependency in Docker.

How it works

  1. At first start, a script will download latest SD-WebUI, some extensions and essential models.

  2. The whole SD-WebUI will be stored in a local folder (./storage/stable-diffusion-webui).

  3. If you already have a SD-WebUI bundle, put it there so the start script will skip downloading.

  4. At every restart of the container, a script will update SD-WebUI & its extensions.

Prerequisites

  • NVIDIA GPU with ≥6GB VRAM (for 4GB see Q & A).

  • Latest NVIDIA GPU Drivers, Both Game and Studio version will work.

  • Docker Installed

Usage

A. Using docker compose
git clone https://github.com/YanWenKun/sd-webui-docker-base.git

cd sd-webui-docker-base

docker compose up --detach

# Update image (only when Python components is outdated)
git pull
docker compose pull
docker compose up --detach --remove-orphans
docker image prune
B. Using docker run
mkdir -p storage

docker run -it \
  --name sd-webui \
  --gpus all \
  -p 7860:7860 \
  -v "$(pwd)"/storage:/home/runner \
  --env CLI_ARGS="--xformers --medvram --allow-code --api --enable-insecure-extension-access" \
  yanwk/sd-webui-base

# Update image (only when Python components is outdated)
docker rm sd-webui
docker pull yanwk/sd-webui-base
# Then re-run 'docker run' above again

Once the app is loaded, visit http://localhost:7860/

For image tag nightly:

  • It builds more frequently.

  • It’s ready for DreamBooth Extension.

  • It come with dev version of xFormers.

    • (Don’t expect performance boost, the stable version is good enough now.)

The base latest will keep simple and easy for people to modify.

Q & A

Q: My GPU only has 4GB VRAM
A: Modify args in CLI_ARGS, change --medvram to --lowvram.

Q: Can I run it without a NVIDIA GPU?
A: Use CPU!

  1. In docker-compose.yml, delete deploy: section.

    • Or in docker run, delete --gpus all.

  2. In CLI_ARGS, change --xformers --medvram to --use-cpu all --no-half --precision full.

More CLI_ARGS available at SD-WebUI Wiki.

Q: Why are you using latest version of dependencies?
A: Try to squeeze more performance out of GPUs (using latest stable version of PyTorch & xFormers).

Q: Will upstream changes break this image?
A: Probably will with major changes in launch.py & requirements_versions.txt, otherwise unlikely. User’s data will always stay safe. User just need to update Docker image after I update this repo.

Some commands for debugging

Build the image, print all logs to STDOUT.
docker build . -f Dockerfile -t yanwk/sd-webui-base --progress=plain
Run a one-time container
docker run -it --rm --gpus all -p 7860:7860 \
  -v "$(pwd)"/storage:/home/runner \
  --env CLI_ARGS="--xformers --medvram" \
  yanwk/sd-webui-base
Run into a root bash
docker run -it --rm --gpus all \
  -v "$(pwd)"/storage:/home/runner \
  -p 7860:7860 \
  --user root \
  -e CLI_ARGS="--xformers --medvram --allow-code --api --enable-insecure-extension-access --ckpt ./test/test_files/empty.pt" \
  yanwk/sd-webui-base:latest /bin/bash

Special Thanks

Thank again for AbdBarho's devotion and brilliant works, which my inspiration emerged from. I would definitely consider webui-docker if I want to deploy multiple WebUIs and only one set of models.

License

This open source license is written and valid both in Chinese and English, how good is that!

About

🐳 Dockerfile for 🖼️ Stable Diffusion WebUI, only runtime environment & bootstrapping scripts. | SD-WebUI 的容器镜像,但仅含运行环境与安装启动脚本。

https://hub.docker.com/r/yanwk/sd-webui-base

License:Mulan Permissive Software License, Version 2


Languages

Language:Shell 60.6%Language:Dockerfile 39.4%