From 602a1c6e627c2ed6fa15e67bf9354ae7650e7864 Mon Sep 17 00:00:00 2001 From: Cloud Axes Date: Wed, 6 Sep 2023 12:12:59 +0900 Subject: [PATCH 1/5] Factor out the git commit sha for the Stable Diffusion Webui The requirements_versions.txt file has been updated several times in the Automatic1111 Stable Diffusion Webui. It's better to synchronize the pip installation between the download and runtime Docker targets. --- services/AUTOMATIC1111/Dockerfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index 25ffcac5b..54d4983e7 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -40,11 +40,12 @@ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip pip install /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl torchvision --index-url https://download.pytorch.org/whl/cu118 +ARG STABLE_DIFFUDION_WEBUI_SHA=c9c8485bc1e8720aba70f029d25cba1c4abf2b5c RUN --mount=type=cache,target=/root/.cache/pip \ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ cd stable-diffusion-webui && \ - git reset --hard 20ae71faa8ef035c31aa3a410b707d792c8203a3 && \ + git reset --hard ${STABLE_DIFFUDION_WEBUI_SHA} && \ pip install -r requirements_versions.txt RUN --mount=type=cache,target=/root/.cache/pip \ @@ -65,18 +66,14 @@ RUN --mount=type=cache,target=/root/.cache/pip \ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \ git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b -# Note: don't update the sha of previous versions because the install will take forever -# instead, update the repo state in a later step - # TODO: either remove if fixed in A1111 (unlikely) or move to the top with other apt stuff RUN apt-get -y install libgoogle-perftools-dev && apt-get clean ENV LD_PRELOAD=libtcmalloc.so -ARG SHA=c9c8485bc1e8720aba70f029d25cba1c4abf2b5c RUN --mount=type=cache,target=/root/.cache/pip \ cd stable-diffusion-webui && \ git fetch && \ - git reset --hard ${SHA} && \ + git reset --hard ${STABLE_DIFFUDION_WEBUI_SHA} && \ pip install -r requirements_versions.txt COPY . /docker From e66ad8924435069a854eb9f7fdfa5ee777f3b888 Mon Sep 17 00:00:00 2001 From: Cloud Axes Date: Wed, 6 Sep 2023 12:17:59 +0900 Subject: [PATCH 2/5] Update Automatic1111 Stable Diffusion Webui to v1.6.0. --- services/AUTOMATIC1111/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index 54d4983e7..adde7517f 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -40,7 +40,7 @@ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip pip install /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl torchvision --index-url https://download.pytorch.org/whl/cu118 -ARG STABLE_DIFFUDION_WEBUI_SHA=c9c8485bc1e8720aba70f029d25cba1c4abf2b5c +ARG STABLE_DIFFUDION_WEBUI_SHA=5ef669de080814067961f28357256e8fe27544f4 # Automatic1111 Stable Diffusion Webui v1.6.0 Aug 31, 2023 RUN --mount=type=cache,target=/root/.cache/pip \ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ From 89ce3da7e3c1e2c20e0c337c8c0789c350febed3 Mon Sep 17 00:00:00 2001 From: Cloud Axes Date: Sat, 9 Sep 2023 20:23:30 +0900 Subject: [PATCH 3/5] Upgrade dependent libraries to what Automatic1111/stable-diffusion-webui uses. Remove taming-transformers because it's no longer used. Change how clip_interrogator files are copied because that repo changed its directory structure in the meantime. --- services/AUTOMATIC1111/Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index adde7517f..4a27c3490 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -2,19 +2,17 @@ FROM alpine/git:2.36.2 as download COPY clone.sh /clone.sh -RUN . /clone.sh taming-transformers https://github.com/CompVis/taming-transformers.git 24268930bf1dce879235a7fddd0b2355b84d7ea6 \ - && rm -rf data assets **/*.ipynb -RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git 47b6b607fdd31875c9279cd2f4f16b92e4ea958e \ +RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf \ && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif RUN . /clone.sh CodeFormer https://github.com/sczhou/CodeFormer.git c5b4593074ba6214284d6acd5f1719b6c5d739af \ && rm -rf assets inputs RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9 -RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git c9fe758757e022f05ca5a53fa8fac28889e4f1cf -RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2486589f24165c8e3b303f84e9dbbea318df83e8 -RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 5c10deee76adad0032b412294130090932317a87 +RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c +RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9 +RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f FROM alpine:3.17 as xformers @@ -56,7 +54,7 @@ ENV ROOT=/stable-diffusion-webui COPY --from=download /repositories/ ${ROOT}/repositories/ -RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/data/* ${ROOT}/interrogate +RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate RUN --mount=type=cache,target=/root/.cache/pip \ pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt From af722a14479257545719ef35f9381abae3869507 Mon Sep 17 00:00:00 2001 From: AbdBarho Date: Sat, 9 Sep 2023 16:01:34 +0200 Subject: [PATCH 4/5] clean up --- docker-compose.yml | 2 +- services/AUTOMATIC1111/Dockerfile | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9157684b4..93fba1dc5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: <<: *base_service profiles: ["auto"] build: ./services/AUTOMATIC1111 - image: sd-auto:65 + image: sd-auto:67 environment: - CLI_ARGS=--allow-code --medvram --xformers --enable-insecure-extension-access --api diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index 4a27c3490..403de3731 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -38,12 +38,10 @@ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip pip install /cache/torch-2.0.1-cp310-cp310-linux_x86_64.whl torchvision --index-url https://download.pytorch.org/whl/cu118 -ARG STABLE_DIFFUDION_WEBUI_SHA=5ef669de080814067961f28357256e8fe27544f4 # Automatic1111 Stable Diffusion Webui v1.6.0 Aug 31, 2023 - RUN --mount=type=cache,target=/root/.cache/pip \ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ cd stable-diffusion-webui && \ - git reset --hard ${STABLE_DIFFUDION_WEBUI_SHA} && \ + git reset --hard 5ef669de080814067961f28357256e8fe27544f4 && \ pip install -r requirements_versions.txt RUN --mount=type=cache,target=/root/.cache/pip \ @@ -64,14 +62,19 @@ RUN --mount=type=cache,target=/root/.cache/pip \ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \ git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b + +# Note: don't update the sha of previous versions because the install will take forever +# instead, update the repo state in a later step + # TODO: either remove if fixed in A1111 (unlikely) or move to the top with other apt stuff RUN apt-get -y install libgoogle-perftools-dev && apt-get clean ENV LD_PRELOAD=libtcmalloc.so +ARG SHA=c9c8485bc1e8720aba70f029d25cba1c4abf2b5c RUN --mount=type=cache,target=/root/.cache/pip \ cd stable-diffusion-webui && \ git fetch && \ - git reset --hard ${STABLE_DIFFUDION_WEBUI_SHA} && \ + git reset --hard ${SHA} && \ pip install -r requirements_versions.txt COPY . /docker From 259cf4d9c1ad64d1cee50b42727195979ee28b90 Mon Sep 17 00:00:00 2001 From: AbdBarho Date: Sat, 9 Sep 2023 16:03:12 +0200 Subject: [PATCH 5/5] actually use newest SHA --- services/AUTOMATIC1111/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile index 403de3731..f380f3094 100644 --- a/services/AUTOMATIC1111/Dockerfile +++ b/services/AUTOMATIC1111/Dockerfile @@ -70,7 +70,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \ RUN apt-get -y install libgoogle-perftools-dev && apt-get clean ENV LD_PRELOAD=libtcmalloc.so -ARG SHA=c9c8485bc1e8720aba70f029d25cba1c4abf2b5c +ARG SHA=5ef669de080814067961f28357256e8fe27544f4 RUN --mount=type=cache,target=/root/.cache/pip \ cd stable-diffusion-webui && \ git fetch && \