From c6724adf6172a4b394af77a59abab32ae46ca657 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Tue, 22 Oct 2024 15:12:11 +0200 Subject: [PATCH 01/15] ci: added workflow to build the image automatically --- .../stable-diffusion-web-ui-production.yml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/stable-diffusion-web-ui-production.yml diff --git a/.github/stable-diffusion-web-ui-production.yml b/.github/stable-diffusion-web-ui-production.yml new file mode 100644 index 00000000..24a8c6a3 --- /dev/null +++ b/.github/stable-diffusion-web-ui-production.yml @@ -0,0 +1,51 @@ +name: Build and Push Stable Diffusion WebUI Docker Image + +on: + workflow_dispatch: + push: + paths: + - "containers/official-templates/stable-diffusion-webui/**" + branches-ignore: + - main + +jobs: + build: + name: Build and Push Docker Image + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Clear space to remove unused folders + run: | + rm -rf /usr/share/dotnet + rm -rf /opt/ghc + rm -rf "/usr/local/share/boost" + rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Set up Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Log in to Docker Hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set environment variables + run: | + echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV + echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV + echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV + + - name: Build and Push Docker Image + working-directory: containers/official-templates/stable-diffusion-webui + uses: docker/bake-action@v2 + with: + push: true From f32cf91f506869b836376df1704f7e28e1ddd9c7 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 23 Oct 2024 23:21:55 +0200 Subject: [PATCH 02/15] ci: get rid of unused env variables --- .github/stable-diffusion-web-ui-production.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/stable-diffusion-web-ui-production.yml b/.github/stable-diffusion-web-ui-production.yml index 24a8c6a3..dcef00b3 100644 --- a/.github/stable-diffusion-web-ui-production.yml +++ b/.github/stable-diffusion-web-ui-production.yml @@ -38,12 +38,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set environment variables - run: | - echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV - echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV - echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV - - name: Build and Push Docker Image working-directory: containers/official-templates/stable-diffusion-webui uses: docker/bake-action@v2 From 55f152ad914c735a052f09c681631b9d8c769e08 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 23 Oct 2024 23:58:00 +0200 Subject: [PATCH 03/15] feat: compatibility with a1111 1.10.0; layer optimizaitions --- .../stable-diffusion-webui/Dockerfile | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/official-templates/stable-diffusion-webui/Dockerfile b/official-templates/stable-diffusion-webui/Dockerfile index 92958b68..68c9baed 100644 --- a/official-templates/stable-diffusion-webui/Dockerfile +++ b/official-templates/stable-diffusion-webui/Dockerfile @@ -1,8 +1,6 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 ARG WEBUI_VERSION -ARG TORCH_VERSION -ARG XFORMERS_VERSION ENV DEBIAN_FRONTEND noninteractive ENV SHELL=/bin/bash @@ -32,51 +30,44 @@ RUN add-apt-repository ppa:deadsnakes/ppa && \ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \python get-pip.py && \ pip install -U --no-cache-dir pip -# Cache Models -RUN mkdir /sd-models && mkdir /cn-models && \ - wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.ckpt -O /sd-models/v1-5-pruned.ckpt && \ - wget https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors -O /sd-models/sd_xl_base_1.0.safetensors && \ - wget https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors -O /sd-models/sd_xl_refiner_1.0.safetensors && \ - wget https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth -O /cn-models/control_v11p_sd15_canny.pth - # Create a virtual environment RUN python -m venv /workspace/venv && \ pip install -U --no-cache-dir jupyterlab jupyterlab_widgets ipykernel ipywidgets +WORKDIR / + # Install Automatic1111's WebUI RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ - cd stable-diffusion-webui && \ + cd /stable-diffusion-webui && \ git checkout tags/${WEBUI_VERSION} && \ - pip install -r requirements_versions.txt && \ + pip install httpx>=0.25.0 xformers && \ + pip install --no-cache-dir --no-deps -r requirements_versions.txt && \ python -c "from launch import prepare_environment; prepare_environment()" --skip-torch-cuda-test -# Install torch and xformers -RUN cd /workspace/stable-diffusion-webui && \ - pip install torch===${TORCH_VERSION} torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 && \ - pip install xformers==${XFORMERS_VERSION} --index-url https://download.pytorch.org/whl/cu118 +WORKDIR /stable-diffusion-webui + +# Apply hotfix to replace `pytorch_lightning.utilities.distributed` with `pytorch_lightning.utilities.rank_zero` +# see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11458#issuecomment-1609900319 +RUN sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ + repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py && \ + sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ + extensions-builtin/LDSR/sd_hijack_ddpm_v1.py # Install DeForum -RUN cd /workspace/stable-diffusion-webui && \ - git clone https://github.com/deforum-art/sd-webui-deforum extensions/deforum && \ +RUN git clone https://github.com/deforum-art/sd-webui-deforum extensions/deforum && \ cd extensions/deforum && \ pip install basicsr && \ pip install -r requirements.txt # Install ControlNet -RUN cd /workspace/stable-diffusion-webui && \ - git clone https://github.com/Mikubill/sd-webui-controlnet.git extensions/sd-webui-controlnet && \ +RUN git clone https://github.com/Mikubill/sd-webui-controlnet.git extensions/sd-webui-controlnet && \ cd extensions/sd-webui-controlnet && \ pip install -r requirements.txt -COPY cache-sd-model.py /workspace/stable-diffusion-webui/ -RUN cd /workspace/stable-diffusion-webui/ && \ - python cache-sd-model.py --use-cpu=all --ckpt /sd-models/SDv1-5.ckpt +WORKDIR / RUN mv /workspace/venv /venv && \ - mv /workspace/stable-diffusion-webui /stable-diffusion-webui && \ - mkdir /workspace/downloader && git clone https://github.com/jjangga0214/sd-models-downloader.git /workspace/downloader - -COPY relauncher.py webui-user.sh /stable-diffusion-webui/ + mkdir -p /workspace/downloader && git clone https://github.com/jjangga0214/sd-models-downloader.git /workspace/downloader # NGINX Proxy COPY --from=proxy nginx.conf /etc/nginx/nginx.conf @@ -85,6 +76,12 @@ COPY --from=proxy readme.html /usr/share/nginx/html/readme.html # Copy the README.md COPY README.md /usr/share/nginx/html/README.md +WORKDIR /stable-diffusion-webui + +COPY relauncher.py webui-user.sh ./ + +WORKDIR /workspace + # Start Scripts COPY pre_start.sh /pre_start.sh COPY --from=scripts start.sh / From 4df2b742aa653a816eea877ac98d348a52f16523 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 23 Oct 2024 23:58:21 +0200 Subject: [PATCH 04/15] feat: update to a1111 1.10.0 --- official-templates/stable-diffusion-webui/docker-bake.hcl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/official-templates/stable-diffusion-webui/docker-bake.hcl b/official-templates/stable-diffusion-webui/docker-bake.hcl index 72f72229..ed54c85b 100644 --- a/official-templates/stable-diffusion-webui/docker-bake.hcl +++ b/official-templates/stable-diffusion-webui/docker-bake.hcl @@ -1,5 +1,5 @@ variable "RELEASE" { - default = "12.0.0" + default = "13.0.0" } target "default" { @@ -10,8 +10,7 @@ target "default" { proxy = "../../container-template/proxy" } args = { - WEBUI_VERSION = "v1.8.0" - TORCH_VERSION = "2.1.2+cu118" - XFORMERS_VERSION = "0.0.23.post1+cu118" + WEBUI_VERSION = "v1.10.0" } + platforms = ["linux/amd64"] } From 7f51aad1f4c0069c514acac304b05e62996c6373 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 24 Oct 2024 00:00:39 +0200 Subject: [PATCH 05/15] feat: create symlinks for the models from the cache --- .../stable-diffusion-webui/pre_start.sh | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/official-templates/stable-diffusion-webui/pre_start.sh b/official-templates/stable-diffusion-webui/pre_start.sh index 230de374..ac6317c2 100644 --- a/official-templates/stable-diffusion-webui/pre_start.sh +++ b/official-templates/stable-diffusion-webui/pre_start.sh @@ -3,13 +3,26 @@ rsync --remove-source-files -rlptDu --ignore-existing /venv/ /workspace/venv/ echo "**** syncing stable diffusion to workspace, please wait ****" rsync --remove-source-files -rlptDu --ignore-existing /stable-diffusion-webui/ /workspace/stable-diffusion-webui/ -ln -s /sd-models/* /workspace/stable-diffusion-webui/models/Stable-diffusion/ -ln -s /cn-models/* /workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/ -if [[ $RUNPOD_STOP_AUTO ]] -then - echo "Skipping auto-start of webui" -else +# Create symbolic links for the models +mkdir -p /workspace/stable-diffusion-webui/models/Stable-diffusion/ +ln -sf /runpod/cache/model/Comfy-Org/stable-diffusion-v1-5-archive/main/v1-5-pruned-emaonly.safetensors /workspace/stable-diffusion-webui/models/Stable-diffusion/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-xl-base-1.0/main/sd_xl_base_1.0.safetensors /workspace/stable-diffusion-webui/models/Stable-diffusion/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-xl-refiner-1.0/main/sd_xl_refiner_1.0.safetensors /workspace/stable-diffusion-webui/models/Stable-diffusion/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-3-medium/main/sd3_medium.safetensors /workspace/stable-diffusion-webui/models/Stable-diffusion/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-3-medium/main/sd3_medium_incl_clips.safetensors /workspace/stable-diffusion-webui/models/Stable-diffusion/ + +# Create symbolic links for clips +mkdir -p /workspace/stable-diffusion-webui/models/Clip/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-3-medium/main/text_encoders/clip_g.safetensors /workspace/stable-diffusion-webui/models/Clip/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-3-medium/main/text_encoders/clip_l.safetensors /workspace/stable-diffusion-webui/models/Clip/ +ln -sf /runpod/cache/model/stabilityai/stable-diffusion-3-medium/main/text_encoders/t5xxl_fp8_e4m3fn.safetensors /workspace/stable-diffusion-webui/models/Clip/ + +# Create symbolic link for ControlNet model +mkdir -p /workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/ +ln -sf /runpod/cache/model/lllyasviel/ControlNet-v1-1/main/control_v11p_sd15_canny.pth /workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/models/ + +if [[ ! $RUNPOD_STOP_AUTO ]]; then echo "Started webui through relauncher script" cd /workspace/stable-diffusion-webui python relauncher.py & From ac989d677f0c3e5dd71f82dc944cebda8497cbed Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 24 Oct 2024 15:32:16 +0200 Subject: [PATCH 06/15] feat: use "subprocess" instead of "os" to have better error handling --- .../stable-diffusion-webui/relauncher.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/official-templates/stable-diffusion-webui/relauncher.py b/official-templates/stable-diffusion-webui/relauncher.py index 168651a3..36fd8798 100644 --- a/official-templates/stable-diffusion-webui/relauncher.py +++ b/official-templates/stable-diffusion-webui/relauncher.py @@ -1,25 +1,18 @@ -import os import time +import subprocess -def relaunch_process(launch_counter=0): - ''' - - ''' +def relaunch_process(): + """Relaunches the web UI process in a loop""" while True: - print('Relauncher: Launching...') - if launch_counter > 0: - print(f'\tRelaunch count: {launch_counter}') - + print("Relauncher: Launching...") try: - launch_string = "/workspace/stable-diffusion-webui/webui.sh -f" - os.system(launch_string) + webui_path = "/workspace/stable-diffusion-webui/webui.sh" + subprocess.run(f"bash {webui_path} -f", shell=True, check=True) except Exception as err: print(f"An error occurred: {err}") - finally: - print('Relauncher: Process is ending. Relaunching in 2s...') - launch_counter += 1 - time.sleep(2) + print("Relauncher: Process is ending. Relaunching in 2s...") + time.sleep(2) if __name__ == "__main__": From 4ad26d3b153f922544374ae76a5c2132125add73 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Thu, 24 Oct 2024 15:34:48 +0200 Subject: [PATCH 07/15] chore: get rid of unnecessary space --- official-templates/stable-diffusion-webui/webui-user.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official-templates/stable-diffusion-webui/webui-user.sh b/official-templates/stable-diffusion-webui/webui-user.sh index 88abdf55..77eb1a80 100644 --- a/official-templates/stable-diffusion-webui/webui-user.sh +++ b/official-templates/stable-diffusion-webui/webui-user.sh @@ -1,4 +1,4 @@ -# #!/bin/bash +#!/bin/bash ######################################################### # Uncomment and change the variables below to your need:# ######################################################### From 01ab817332f42bf3e82c8cefde2a4087b35e7492 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 25 Oct 2024 00:08:28 +0200 Subject: [PATCH 08/15] refactor: move ARG around to improve layer caching; make sure that deps are always up to date --- .../stable-diffusion-webui/Dockerfile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/official-templates/stable-diffusion-webui/Dockerfile b/official-templates/stable-diffusion-webui/Dockerfile index 68c9baed..ecc85eaa 100644 --- a/official-templates/stable-diffusion-webui/Dockerfile +++ b/official-templates/stable-diffusion-webui/Dockerfile @@ -1,7 +1,5 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 -ARG WEBUI_VERSION - ENV DEBIAN_FRONTEND noninteractive ENV SHELL=/bin/bash ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu @@ -13,13 +11,18 @@ WORKDIR /workspace SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install system dependencies -RUN apt update --yes && \ - apt upgrade --yes && \ - apt install --yes --no-install-recommends \ +RUN rm -f /etc/apt/sources.list.d/*.list && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get update --yes && \ + apt-get upgrade --yes && \ + apt-get install --yes --no-install-recommends \ git openssh-server libglib2.0-0 libsm6 libgl1 libxrender1 libxext6 ffmpeg wget curl psmisc rsync vim bc nginx \ pkg-config libffi-dev libcairo2 libcairo2-dev libgoogle-perftools4 libtcmalloc-minimal4 apt-transport-https \ software-properties-common ca-certificates && \ - update-ca-certificates + update-ca-certificates && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* # Install Python 3.10 RUN add-apt-repository ppa:deadsnakes/ppa && \ @@ -36,6 +39,8 @@ RUN python -m venv /workspace/venv && \ WORKDIR / +ARG WEBUI_VERSION + # Install Automatic1111's WebUI RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ cd /stable-diffusion-webui && \ From 2deddccd39201b74614d9342828c654a1a97df28 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 25 Oct 2024 00:08:35 +0200 Subject: [PATCH 09/15] chore: remove unused file --- .../stable-diffusion-webui/cache-sd-model.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 official-templates/stable-diffusion-webui/cache-sd-model.py diff --git a/official-templates/stable-diffusion-webui/cache-sd-model.py b/official-templates/stable-diffusion-webui/cache-sd-model.py deleted file mode 100644 index 9d4da27a..00000000 --- a/official-templates/stable-diffusion-webui/cache-sd-model.py +++ /dev/null @@ -1,7 +0,0 @@ -from webui import initialize -import modules.interrogate - -initialize.initialize() -interrogator = modules.interrogate.InterrogateModels("interrogate") -interrogator.load() -interrogator.categories() From dd6b3549dfbe750bff28af4240b1374cfc7255ea Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 25 Oct 2024 00:08:51 +0200 Subject: [PATCH 10/15] fix: use version 1.9.0 as 1.10.0 is not working --- official-templates/stable-diffusion-webui/docker-bake.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official-templates/stable-diffusion-webui/docker-bake.hcl b/official-templates/stable-diffusion-webui/docker-bake.hcl index ed54c85b..6f84a3db 100644 --- a/official-templates/stable-diffusion-webui/docker-bake.hcl +++ b/official-templates/stable-diffusion-webui/docker-bake.hcl @@ -10,7 +10,7 @@ target "default" { proxy = "../../container-template/proxy" } args = { - WEBUI_VERSION = "v1.10.0" + WEBUI_VERSION = "v1.9.0" } platforms = ["linux/amd64"] } From 6f1a85a126be41f6c3674ea65f585cfc022100ee Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Fri, 25 Oct 2024 00:51:06 +0200 Subject: [PATCH 11/15] ci: move workflow into correct location --- .github/{ => workflows}/stable-diffusion-web-ui-production.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/stable-diffusion-web-ui-production.yml (100%) diff --git a/.github/stable-diffusion-web-ui-production.yml b/.github/workflows/stable-diffusion-web-ui-production.yml similarity index 100% rename from .github/stable-diffusion-web-ui-production.yml rename to .github/workflows/stable-diffusion-web-ui-production.yml From 2c58498b2409e8c6f4368147cf30b7c05b6f8e82 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 13 Nov 2024 12:40:23 +0100 Subject: [PATCH 12/15] fix: don't use "--no-deps" as this is causing problems --- official-templates/stable-diffusion-webui/Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/official-templates/stable-diffusion-webui/Dockerfile b/official-templates/stable-diffusion-webui/Dockerfile index ecc85eaa..96e97f33 100644 --- a/official-templates/stable-diffusion-webui/Dockerfile +++ b/official-templates/stable-diffusion-webui/Dockerfile @@ -46,17 +46,17 @@ RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \ cd /stable-diffusion-webui && \ git checkout tags/${WEBUI_VERSION} && \ pip install httpx>=0.25.0 xformers && \ - pip install --no-cache-dir --no-deps -r requirements_versions.txt && \ + pip install --no-cache-dir -r requirements_versions.txt && \ python -c "from launch import prepare_environment; prepare_environment()" --skip-torch-cuda-test WORKDIR /stable-diffusion-webui # Apply hotfix to replace `pytorch_lightning.utilities.distributed` with `pytorch_lightning.utilities.rank_zero` # see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11458#issuecomment-1609900319 -RUN sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ - repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py && \ - sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ - extensions-builtin/LDSR/sd_hijack_ddpm_v1.py +# RUN sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ +# repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py && \ +# sed -i 's/pytorch_lightning.utilities.distributed/pytorch_lightning.utilities.rank_zero/g' \ +# extensions-builtin/LDSR/sd_hijack_ddpm_v1.py # Install DeForum RUN git clone https://github.com/deforum-art/sd-webui-deforum extensions/deforum && \ @@ -67,6 +67,7 @@ RUN git clone https://github.com/deforum-art/sd-webui-deforum extensions/deforum # Install ControlNet RUN git clone https://github.com/Mikubill/sd-webui-controlnet.git extensions/sd-webui-controlnet && \ cd extensions/sd-webui-controlnet && \ + pip install opencv-python-headless>=4.9.0 && \ pip install -r requirements.txt WORKDIR / From fe22b12b2a4df61233096a3824377618fac2c2b4 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 13 Nov 2024 12:40:51 +0100 Subject: [PATCH 13/15] docs: improved the README to make it clear what users get when using this image --- .../stable-diffusion-webui/README.md | 78 +++++++++++++++---- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/official-templates/stable-diffusion-webui/README.md b/official-templates/stable-diffusion-webui/README.md index c95ce082..b68395c4 100644 --- a/official-templates/stable-diffusion-webui/README.md +++ b/official-templates/stable-diffusion-webui/README.md @@ -1,29 +1,75 @@ -## 🚀 RunPod Automatic1111 Stable Diffusion Template +# Automatic1111 Stable Diffusion WebUI Template -### 📝 General +A ready-to-use template for running Stable Diffusion WebUI (AUTOMATIC1111) on RunPod. -⚠️ **Please note, this doesn't work out-of-the-box with encrypted volumes!** +## Quick Start -This is a RunPod packaged template for stable diffusion using the Automatic1111 repository. RunPod does not maintain the code for this repo, we merely package it for easier use. +1. Wait for the pod to fully initialize (GPU Utilization should be 0%) +2. Access the WebUI through port 3000 +3. Start creating! -If you need help with settings, etc., feel free to ask us, but remember we're not stable diffusion experts! 😅 We'll do our best to assist, but the RunPod community or automatic/stable diffusion communities might be more effective in helping you. +⚠️ **Note**: You may encounter a 502 error if you try to connect before initialization is complete. -🔵 **Please wait until the GPU Utilization % is 0 before attempting to connect. You'll likely encounter a 502 error if the pod is still getting ready for use.** +## Pre-installed Models -### ⚙️ Changing Launch Parameters +The following models are automatically mounted and ready to use: -You might be used to altering a different file for your launch parameters. In our case, we use `relauncher.py` located in the `webui` directory to manage the launch flags like `--xformers`. Feel free to edit this file, and then restart your pod via the hamburger menu for the changes to take effect. `--xformers` and `--api` are commonly inquired about. +### Stable Diffusion Models -### 📥 Using Your Own Models +- [Stable Diffusion XL Base 1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base_1.0.safetensors) +- [Stable Diffusion XL Refiner 1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/blob/main/sd_xl_refiner_1.0.safetensors) +- [Stable Diffusion 1.5](https://huggingface.co/Comfy-Org/stable-diffusion-v1-5-archive/blob/main/v1-5-pruned-emaonly.safetensors) -The best ways to introduce your models to your pod is by using [runpodctl](https://github.com/runpod/runpodctl/blob/main/README.md) or by uploading them to Google Drive or another cloud storage provider and downloading them to your pod from there. +### ControlNet Models -### 🚚 Uploading to Google Drive +- Canny (control_v11p_sd15_canny.pth) -If you're finished with the pod and want to transfer things to Google Drive, [this colab](https://colab.research.google.com/drive/1ot8pODgystx1D6_zvsALDSvjACBF1cj6) can assist you using `runpodctl`. You can run `runpodctl` in a web terminal (found in the pod connect menu), or in a terminal on the desktop. +## Network Ports -## 🔌 Template Ports +| Application | Port | Protocol | Description | +| ---------------------- | ---- | -------- | ----------------------------------- | +| Stable Diffusion WebUI | 3000 | HTTP | Main interface for Stable Diffusion | +| Jupyter Lab | 8888 | HTTP | Python notebook interface | +| SSH | 22 | TCP | Secure shell access | -- **3001** | HTTP - This is the WebUI port that gets proxied to the internal 3000 port. -- **8888** | HTTP - This is the JupyterLab port that gets proxied to the internal 8888 port. -- **22** | TCP - This is the SSH port that gets proxied to the internal 22 port. +## Customization + +### Modifying Launch Parameters + +Launch parameters are configured in `webui-user.sh`. To modify them: + +1. Edit the file in the workspace +2. Restart the pod to apply changes + +Current default parameters include: + +- `--xformers` for optimized memory usage +- `--listen` for network access +- `--enable-insecure-extension-access` for extension support + +## Adding Custom Models + +You have two options for adding your own models: + +1. Using [runpodctl](https://github.com/runpod/runpodctl/blob/main/README.md) +2. Downloading from cloud storage (Google Drive, etc.) + +## Backing Up Your Work + +To save your work to Google Drive: + +1. Use [this Google Colab notebook](https://colab.research.google.com/drive/1ot8pODgystx1D6_zvsALDSvjACBF1cj6) +2. Follow the instructions to transfer files using `runpodctl` + +You can run `runpodctl` either through: + +- The web terminal (in pod connect menu) +- The desktop terminal + +## Important Notes + +- This template doesn't support encrypted volumes +- For technical support, consider: + - [RunPod Community on Discord](https://discord.gg/cUpRmau42V) + - [Automatic1111 GitHub Issues](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues) + - [Stable Diffusion on Reddit](https://www.reddit.com/r/StableDiffusion/) From cd5cf2daa262aaaea7c23b5f2759185d3114e493 Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 13 Nov 2024 12:41:15 +0100 Subject: [PATCH 14/15] feat: updated to v1.10.0 --- official-templates/stable-diffusion-webui/docker-bake.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official-templates/stable-diffusion-webui/docker-bake.hcl b/official-templates/stable-diffusion-webui/docker-bake.hcl index 6f84a3db..ed54c85b 100644 --- a/official-templates/stable-diffusion-webui/docker-bake.hcl +++ b/official-templates/stable-diffusion-webui/docker-bake.hcl @@ -10,7 +10,7 @@ target "default" { proxy = "../../container-template/proxy" } args = { - WEBUI_VERSION = "v1.9.0" + WEBUI_VERSION = "v1.10.0" } platforms = ["linux/amd64"] } From 51de708f9edd0357b4b7556148705184e54ce37d Mon Sep 17 00:00:00 2001 From: Tim Pietrusky Date: Wed, 13 Nov 2024 12:42:29 +0100 Subject: [PATCH 15/15] chore: removed "--skip-torch-cuda-test" --- official-templates/stable-diffusion-webui/webui-user.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/official-templates/stable-diffusion-webui/webui-user.sh b/official-templates/stable-diffusion-webui/webui-user.sh index 77eb1a80..42f94b74 100644 --- a/official-templates/stable-diffusion-webui/webui-user.sh +++ b/official-templates/stable-diffusion-webui/webui-user.sh @@ -10,7 +10,7 @@ install_dir="/workspace" #clone_dir="stable-diffusion-webui" # Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention" -export COMMANDLINE_ARGS="--port 3000 --xformers --skip-install --listen --enable-insecure-extension-access" +export COMMANDLINE_ARGS="--port 3000 --xformers --skip-install --listen --enable-insecure-extension-access --skip-torch-cuda-test" #export XFORMERS_PACKAGE="xformers==0.0.17.dev447" # python3 executable