mirror of
https://github.com/AbdBarho/stable-diffusion-webui-docker.git
synced 2026-02-03 22:24:19 +01:00
Added services for invoke and sygil AMD
This commit is contained in:
parent
2b3a382016
commit
0fedf81d56
|
|
@ -1,76 +0,0 @@
|
|||
version: '3.9'
|
||||
|
||||
x-base_service:
|
||||
&base_service
|
||||
ports:
|
||||
- "7860:7860"
|
||||
volumes:
|
||||
- &v1 ./data:/data
|
||||
- &v2 ./output:/output
|
||||
stop_signal: SIGINT
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
device_ids: [ '0' ]
|
||||
capabilities: [ gpu ]
|
||||
|
||||
name: webui-docker
|
||||
|
||||
services:
|
||||
download:
|
||||
build: ./services/download/
|
||||
profiles: [ "download" ]
|
||||
volumes:
|
||||
- *v1
|
||||
|
||||
auto:
|
||||
&automatic
|
||||
<<: *base_service
|
||||
profiles: [ "auto" ]
|
||||
build: ./services/AUTOMATIC1111
|
||||
image: sd-auto:47
|
||||
environment:
|
||||
- CLI_ARGS=--allow-code --medvram --xformers --enable-insecure-extension-access --api
|
||||
|
||||
auto-amd:
|
||||
&automatic
|
||||
<<: *base_service
|
||||
profiles: [ "auto-amd" ]
|
||||
build: ./services/AUTOMATIC1111-AMD
|
||||
image: sd-auto:47
|
||||
environment:
|
||||
- CLI_ARGS=--allow-code --medvram --enable-insecure-extension-access --api --no-half --precision full --opt-sub-quad-attention
|
||||
|
||||
auto-cpu:
|
||||
<<: *automatic
|
||||
profiles: [ "auto-cpu" ]
|
||||
deploy: {}
|
||||
environment:
|
||||
- CLI_ARGS=--no-half --precision full --allow-code --enable-insecure-extension-access --api
|
||||
|
||||
invoke:
|
||||
<<: *base_service
|
||||
profiles: [ "invoke" ]
|
||||
build: ./services/invoke/
|
||||
image: sd-invoke:26
|
||||
environment:
|
||||
- PRELOAD=true
|
||||
- CLI_ARGS=
|
||||
|
||||
sygil:
|
||||
&sygil
|
||||
<<: *base_service
|
||||
profiles: [ "sygil" ]
|
||||
build: ./services/sygil/
|
||||
image: sd-sygil:16
|
||||
environment:
|
||||
- CLI_ARGS=--optimized-turbo
|
||||
- USE_STREAMLIT=0
|
||||
|
||||
sygil-sl:
|
||||
<<: *sygil
|
||||
profiles: [ "sygil-sl" ]
|
||||
environment:
|
||||
- USE_STREAMLIT=1
|
||||
|
|
@ -1,63 +1,109 @@
|
|||
version: '3.9'
|
||||
|
||||
x-base_service: &base_service
|
||||
ports:
|
||||
- "7860:7860"
|
||||
volumes:
|
||||
- &v1 ./data:/data
|
||||
- &v2 ./output:/output
|
||||
stop_signal: SIGINT
|
||||
group_add:
|
||||
- video
|
||||
devices:
|
||||
- "/dev/dri"
|
||||
- "/dev/kfd"
|
||||
x-base_service:
|
||||
&base_service
|
||||
ports:
|
||||
- "7860:7860"
|
||||
volumes:
|
||||
- &v1 ./data:/data
|
||||
- &v2 ./output:/output
|
||||
stop_signal: SIGINT
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
device_ids: [ '0' ]
|
||||
capabilities: [ gpu ]
|
||||
|
||||
x-base_service_amd:
|
||||
&base_service_amd
|
||||
ports:
|
||||
- "7860:7860"
|
||||
volumes:
|
||||
- &v1 ./data:/data
|
||||
- &v2 ./output:/output
|
||||
stop_signal: SIGINT
|
||||
group_add:
|
||||
- video
|
||||
devices:
|
||||
- "/dev/dri"
|
||||
- "/dev/kfd"
|
||||
|
||||
name: webui-docker
|
||||
|
||||
services:
|
||||
download:
|
||||
build: ./services/download/
|
||||
profiles: ["download"]
|
||||
profiles: [ "download" ]
|
||||
volumes:
|
||||
- *v1
|
||||
|
||||
auto: &automatic
|
||||
auto:
|
||||
&automatic
|
||||
<<: *base_service
|
||||
profiles: ["auto"]
|
||||
profiles: [ "auto" ]
|
||||
build: ./services/AUTOMATIC1111
|
||||
image: sd-auto:48
|
||||
environment:
|
||||
- CLI_ARGS=--allow-code --medvram --enable-insecure-extension-access --api
|
||||
|
||||
auto-amd:
|
||||
&automatic
|
||||
<<: *base_service_amd
|
||||
profiles: [ "auto-amd" ]
|
||||
build: ./services/AUTOMATIC1111-AMD
|
||||
image: sd-auto:48
|
||||
environment:
|
||||
- CLI_ARGS=--allow-code --medvram --no-half --precision full --enable-insecure-extension-access --api
|
||||
|
||||
auto-cpu:
|
||||
<<: *automatic
|
||||
profiles: ["auto-cpu"]
|
||||
profiles: [ "auto-cpu" ]
|
||||
deploy: {}
|
||||
environment:
|
||||
- CLI_ARGS=--no-half --precision full --allow-code --enable-insecure-extension-access --api
|
||||
|
||||
invoke:
|
||||
<<: *base_service
|
||||
profiles: ["invoke"]
|
||||
profiles: [ "invoke" ]
|
||||
build: ./services/invoke/
|
||||
image: sd-invoke:26
|
||||
environment:
|
||||
- PRELOAD=true
|
||||
- CLI_ARGS=
|
||||
|
||||
invoke-amd:
|
||||
<<: *base_service_amd
|
||||
profiles: [ "invoke-amd" ]
|
||||
build: ./services/invoke-AMD/
|
||||
image: sd-invoke:26
|
||||
environment:
|
||||
- PRELOAD=true
|
||||
- CLI_ARGS=
|
||||
|
||||
sygil: &sygil
|
||||
sygil:
|
||||
&sygil
|
||||
<<: *base_service
|
||||
profiles: ["sygil"]
|
||||
profiles: [ "sygil" ]
|
||||
build: ./services/sygil/
|
||||
image: sd-sygil:16
|
||||
environment:
|
||||
- CLI_ARGS=--optimized-turbo
|
||||
- USE_STREAMLIT=0
|
||||
|
||||
sygil-amd:
|
||||
&sygil
|
||||
<<: *base_service_amd
|
||||
profiles: [ "sygil-amd" ]
|
||||
build: ./services/sygil-AMD/
|
||||
image: sd-sygil:16
|
||||
environment:
|
||||
- CLI_ARGS=--optimized-turbo
|
||||
- USE_STREAMLIT=0
|
||||
|
||||
sygil-sl:
|
||||
<<: *sygil
|
||||
profiles: ["sygil-sl"]
|
||||
profiles: [ "sygil-sl" ]
|
||||
environment:
|
||||
- USE_STREAMLIT=1
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ SHELL ["/bin/bash", "-ceuxo", "pipefail"]
|
|||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
|
||||
|
||||
RUN PIP_NO_CACHE_DIR=1 pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.2
|
||||
RUN PIP_NO_CACHE_DIR=1 pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.2
|
||||
|
||||
RUN apt-get update && apt install fonts-dejavu-core rsync git jq moreutils bash -y && apt-get clean
|
||||
|
||||
|
|
@ -86,5 +86,8 @@ WORKDIR ${ROOT}
|
|||
ENV CLI_ARGS=""
|
||||
EXPOSE 7860
|
||||
ENTRYPOINT ["/docker/entrypoint.sh"]
|
||||
|
||||
# Depending on your actual GPU you may want to comment this out.
|
||||
# Without this you may get the error "hipErrorNoBinaryForGpu: Unable to find code object for all current devices!"
|
||||
ENV HSA_OVERRIDE_GFX_VERSION=10.3.0
|
||||
CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}
|
||||
|
|
|
|||
71
services/invoke-AMD/Dockerfile
Normal file
71
services/invoke-AMD/Dockerfile
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM alpine:3.17 as xformers
|
||||
RUN apk add --no-cache aria2
|
||||
RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl'
|
||||
|
||||
|
||||
|
||||
FROM python:3.10-slim
|
||||
SHELL ["/bin/bash", "-ceuxo", "pipefail"]
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_EXISTS_ACTION=w PIP_PREFER_BINARY=1
|
||||
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.2
|
||||
|
||||
RUN apt-get update && apt-get install git -y && apt-get clean
|
||||
|
||||
RUN git clone https://github.com/invoke-ai/InvokeAI.git /stable-diffusion
|
||||
|
||||
WORKDIR /stable-diffusion
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
|
||||
git reset --hard f232068ab89bd80e4f5f3133dcdb62ea78f1d0f7
|
||||
git config --global http.postBuffer 1048576000
|
||||
egrep -v '^-e .' environments-and-requirements/requirements-lin-cuda.txt > req.txt
|
||||
pip install -r req.txt
|
||||
rm req.txt
|
||||
EOF
|
||||
|
||||
|
||||
# patch match:
|
||||
# https://github.com/invoke-ai/InvokeAI/blob/main/docs/installation/INSTALL_PATCHMATCH.md
|
||||
RUN <<EOF
|
||||
apt-get update
|
||||
# apt-get install build-essential python3-opencv libopencv-dev -y
|
||||
apt-get install make g++ libopencv-dev -y
|
||||
apt-get clean
|
||||
cd /usr/lib/x86_64-linux-gnu/pkgconfig/
|
||||
ln -sf opencv4.pc opencv.pc
|
||||
EOF
|
||||
|
||||
|
||||
ARG BRANCH=main SHA=6e0c6d9cc9f6bdbdefc4b9e94bc1ccde1b04aa42
|
||||
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
|
||||
git fetch
|
||||
git reset --hard
|
||||
git checkout ${BRANCH}
|
||||
git reset --hard ${SHA}
|
||||
pip install .
|
||||
EOF
|
||||
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.15-cp310-cp310-linux_x86_64.whl \
|
||||
pip install -U opencv-python-headless huggingface_hub triton /xformers-0.0.15-cp310-cp310-linux_x86_64.whl && \
|
||||
python3 -c "from patchmatch import patch_match"
|
||||
|
||||
|
||||
RUN touch invokeai.init
|
||||
COPY . /docker/
|
||||
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 ROOT=/stable-diffusion PYTHONPATH="${PYTHONPATH}:${ROOT}" PRELOAD=false CLI_ARGS="" HF_HOME=/root/.cache/huggingface
|
||||
EXPOSE 7860
|
||||
ENTRYPOINT ["/docker/entrypoint.sh"]
|
||||
|
||||
# Depending on your actual GPU you may want to comment this out.
|
||||
# Without this you may get the error "hipErrorNoBinaryForGpu: Unable to find code object for all current devices!"
|
||||
ENV HSA_OVERRIDE_GFX_VERSION=10.3.0
|
||||
CMD invokeai --web --host 0.0.0.0 --port 7860 --config /docker/models.yaml --root_dir ${ROOT} --outdir /output/invoke ${CLI_ARGS}
|
||||
46
services/invoke-AMD/entrypoint.sh
Executable file
46
services/invoke-AMD/entrypoint.sh
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
declare -A MOUNTS
|
||||
|
||||
# cache
|
||||
MOUNTS["/root/.cache"]=/data/.cache/
|
||||
|
||||
# ui specific
|
||||
MOUNTS["${ROOT}/models/codeformer"]=/data/Codeformer/
|
||||
|
||||
MOUNTS["${ROOT}/models/gfpgan/GFPGANv1.4.pth"]=/data/GFPGAN/GFPGANv1.4.pth
|
||||
MOUNTS["${ROOT}/models/gfpgan/weights"]=/data/.cache/
|
||||
|
||||
MOUNTS["${ROOT}/models/realesrgan"]=/data/RealESRGAN/
|
||||
|
||||
MOUNTS["${ROOT}/models/bert-base-uncased"]=/data/.cache/huggingface/transformers/
|
||||
MOUNTS["${ROOT}/models/openai/clip-vit-large-patch14"]=/data/.cache/huggingface/transformers/
|
||||
MOUNTS["${ROOT}/models/CompVis/stable-diffusion-safety-checker"]=/data/.cache/huggingface/transformers/
|
||||
|
||||
MOUNTS["${ROOT}/embeddings"]=/data/embeddings/
|
||||
|
||||
# hacks
|
||||
MOUNTS["${ROOT}/models/clipseg"]=/data/.cache/invoke/clipseg/
|
||||
|
||||
for to_path in "${!MOUNTS[@]}"; do
|
||||
set -Eeuo pipefail
|
||||
from_path="${MOUNTS[${to_path}]}"
|
||||
rm -rf "${to_path}"
|
||||
mkdir -p "$(dirname "${to_path}")"
|
||||
# ends with slash, make it!
|
||||
if [[ "$from_path" == */ ]]; then
|
||||
mkdir -vp "$from_path"
|
||||
fi
|
||||
|
||||
ln -sT "${from_path}" "${to_path}"
|
||||
echo Mounted $(basename "${from_path}")
|
||||
done
|
||||
|
||||
if "${PRELOAD}" == "true"; then
|
||||
set -Eeuo pipefail
|
||||
invokeai-configure --skip-sd-weights --root ${ROOT} --yes
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
23
services/invoke-AMD/models.yaml
Normal file
23
services/invoke-AMD/models.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# This file describes the alternative machine learning models
|
||||
# available to InvokeAI script.
|
||||
#
|
||||
# To add a new model, follow the examples below. Each
|
||||
# model requires a model config file, a weights file,
|
||||
# and the width and height of the images it
|
||||
# was trained on.
|
||||
stable-diffusion-1.5:
|
||||
description: Stable Diffusion version 1.5
|
||||
weights: /data/StableDiffusion/v1-5-pruned-emaonly.ckpt
|
||||
vae: /data/VAE/vae-ft-mse-840000-ema-pruned.ckpt
|
||||
config: ./invokeai/configs/stable-diffusion/v1-inference.yaml
|
||||
width: 512
|
||||
height: 512
|
||||
default: true
|
||||
inpainting-1.5:
|
||||
description: RunwayML SD 1.5 model optimized for inpainting
|
||||
weights: /data/StableDiffusion/sd-v1-5-inpainting.ckpt
|
||||
vae: /data/VAE/vae-ft-mse-840000-ema-pruned.ckpt
|
||||
config: ./invokeai/configs/stable-diffusion/v1-inpainting-inference.yaml
|
||||
width: 512
|
||||
height: 512
|
||||
default: false
|
||||
49
services/sygil-AMD/Dockerfile
Normal file
49
services/sygil-AMD/Dockerfile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM python:3.8-slim
|
||||
|
||||
SHELL ["/bin/bash", "-ceuxo", "pipefail"]
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip pip install torch==1.13.0 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.2
|
||||
|
||||
RUN apt-get update && apt install gcc libsndfile1 ffmpeg build-essential zip unzip git -y && apt-get clean
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
|
||||
git config --global http.postBuffer 1048576000
|
||||
git clone https://github.com/Sygil-Dev/sygil-webui.git stable-diffusion
|
||||
cd stable-diffusion
|
||||
git reset --hard 5291437085bddd16d752f811b6552419a2044d12
|
||||
pip install -r requirements.txt
|
||||
EOF
|
||||
|
||||
|
||||
ARG BRANCH=master SHA=571fb897edd58b714bb385dfaa1ad59aecef8bc7
|
||||
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
|
||||
cd stable-diffusion
|
||||
git fetch
|
||||
git checkout ${BRANCH}
|
||||
git reset --hard ${SHA}
|
||||
pip install -r requirements.txt
|
||||
EOF
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip pip install -U 'transformers>=4.24'
|
||||
|
||||
# add info
|
||||
COPY . /docker/
|
||||
RUN <<EOF
|
||||
python /docker/info.py /stable-diffusion/frontend/frontend.py
|
||||
chmod +x /docker/mount.sh /docker/run.sh
|
||||
# streamlit
|
||||
sed -i -- 's/8501/7860/g' /stable-diffusion/.streamlit/config.toml
|
||||
EOF
|
||||
|
||||
WORKDIR /stable-diffusion
|
||||
ENV PYTHONPATH="${PYTHONPATH}:${PWD}" STREAMLIT_SERVER_HEADLESS=true USE_STREAMLIT=0 CLI_ARGS=""
|
||||
EXPOSE 7860
|
||||
|
||||
# Depending on your actual GPU you may want to comment this out.
|
||||
# Without this you may get the error "hipErrorNoBinaryForGpu: Unable to find code object for all current devices!"
|
||||
ENV HSA_OVERRIDE_GFX_VERSION=10.3.0
|
||||
CMD /docker/mount.sh && /docker/run.sh
|
||||
13
services/sygil-AMD/info.py
Normal file
13
services/sygil-AMD/info.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
file = Path(sys.argv[1])
|
||||
file.write_text(
|
||||
file.read_text()\
|
||||
.replace('<p>For help and advanced usage guides,', """
|
||||
<p>
|
||||
Created using <a href="https://github.com/AbdBarho/stable-diffusion-webui-docker">stable-diffusion-webui-docker</a>.
|
||||
</p>
|
||||
<p>For help and advanced usage guides,
|
||||
""", 1)
|
||||
)
|
||||
32
services/sygil-AMD/mount.sh
Executable file
32
services/sygil-AMD/mount.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
declare -A MOUNTS
|
||||
|
||||
ROOT=/stable-diffusion/src
|
||||
|
||||
# cache
|
||||
MOUNTS["/root/.cache"]=/data/.cache
|
||||
# ui specific
|
||||
MOUNTS["${PWD}/models/realesrgan"]=/data/RealESRGAN
|
||||
MOUNTS["${PWD}/models/ldsr"]=/data/LDSR
|
||||
MOUNTS["${PWD}/models/custom"]=/data/StableDiffusion
|
||||
|
||||
# hack
|
||||
MOUNTS["${PWD}/models/gfpgan/GFPGANv1.3.pth"]=/data/GFPGAN/GFPGANv1.4.pth
|
||||
MOUNTS["${PWD}/models/gfpgan/GFPGANv1.4.pth"]=/data/GFPGAN/GFPGANv1.4.pth
|
||||
MOUNTS["${PWD}/gfpgan/weights"]=/data/.cache
|
||||
|
||||
|
||||
for to_path in "${!MOUNTS[@]}"; do
|
||||
set -Eeuo pipefail
|
||||
from_path="${MOUNTS[${to_path}]}"
|
||||
rm -rf "${to_path}"
|
||||
mkdir -p "$(dirname "${to_path}")"
|
||||
ln -sT "${from_path}" "${to_path}"
|
||||
echo Mounted $(basename "${from_path}")
|
||||
done
|
||||
|
||||
# streamlit config
|
||||
ln -sf /docker/userconfig_streamlit.yaml /stable-diffusion/configs/webui/userconfig_streamlit.yaml
|
||||
10
services/sygil-AMD/run.sh
Executable file
10
services/sygil-AMD/run.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
echo "USE_STREAMLIT = ${USE_STREAMLIT}"
|
||||
if [ "${USE_STREAMLIT}" == "1" ]; then
|
||||
python -u -m streamlit run scripts/webui_streamlit.py
|
||||
else
|
||||
python3 -u scripts/webui.py --outdir /output --ckpt /data/StableDiffusion/v1-5-pruned-emaonly.ckpt ${CLI_ARGS}
|
||||
fi
|
||||
11
services/sygil-AMD/userconfig_streamlit.yaml
Normal file
11
services/sygil-AMD/userconfig_streamlit.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# https://github.com/Sygil-Dev/sygil-webui/blob/master/configs/webui/webui_streamlit.yaml
|
||||
general:
|
||||
version: 1.24.6
|
||||
outdir: /output
|
||||
default_model: "Stable Diffusion v1.5"
|
||||
default_model_path: /data/StableDiffusion/v1-5-pruned-emaonly.ckpt
|
||||
outdir_txt2img: /output/txt2img
|
||||
outdir_img2img: /output/img2img
|
||||
outdir_img2txt: /output/img2txt
|
||||
optimized: True
|
||||
optimized_turbo: True
|
||||
Loading…
Reference in a new issue