From fd06c3f6d38e86246920e7c5f4f7b8601770f365 Mon Sep 17 00:00:00 2001 From: Rob Ballantyne Date: Fri, 2 Aug 2024 20:29:38 +0100 Subject: [PATCH] Prepare for new default CUDA version and add DockerHub images --- .github/workflows/docker-build.yml | 82 +++++--- README.md | 22 +-- .../opt/ai-dock/bin/preflight.d/10-default.sh | 7 +- .../opt/ai-dock/bin/set-webui-args | 1 + .../opt/ai-dock/bin/set-webui-args.sh | 4 + .../opt/ai-dock/bin/set-webui-flags | 1 + .../opt/ai-dock/bin/set-webui-flags.sh | 5 +- .../opt/ai-dock/bin/supervisor-webui.sh | 10 +- config/provisioning/default-rocm.sh | 10 +- config/provisioning/default.sh | 10 +- config/provisioning/newbase-rocm.sh | 178 ----------------- config/provisioning/newbase.sh | 181 ------------------ docker-compose.yaml | 2 +- 13 files changed, 90 insertions(+), 423 deletions(-) create mode 120000 build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args create mode 100755 build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args.sh create mode 120000 build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags mode change 100755 => 120000 build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh delete mode 100755 config/provisioning/newbase-rocm.sh delete mode 100755 config/provisioning/newbase.sh diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 268341e..19f3e68 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -17,7 +17,7 @@ jobs: matrix: build: # Undeclared release tag finds latest from GitHub tags - - {latest: "true", tag: "v1.9.4", python: "3.10", pytorch: "2.3.0"} + - {latest: "false", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1"} steps: - name: Free Space @@ -33,19 +33,26 @@ jobs: - name: Env Setter run: | - echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} + REPO=${GITHUB_REPOSITORY,,} + echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV} + echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV} - name: Checkout uses: actions/checkout@v3 - name: Permissions fixes run: | - reponame="$(basename ${GITHUB_REPOSITORY})" - target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/build/COPY*" chmod -R ug+rwX ${target} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -53,7 +60,7 @@ jobs: - name: Set tags run: | - img_path="ghcr.io/${{ env.PACKAGE_NAME }}" + img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}" if [[ -z '${{ matrix.build.tag }}' ]]; then WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')" else @@ -66,9 +73,9 @@ jobs: if [[ ${{ matrix.build.latest }} == "true" ]]; then echo "Marking latest" - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}, ${img_path}:${base_tag}, ${img_path}:latest-cpu, ${img_path}:latest-cpu-jupyter" + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu" else - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}" + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - @@ -93,8 +100,7 @@ jobs: matrix: build: # Undeclared release tag finds latest from GitHub tags - - {latest: "true", tag: "v1.9.4", python: "3.10", pytorch: "2.3.0", cuda: "11.8.0-base"} - - {latest: "false", tag: "v1.9.4", python: "3.10", pytorch: "2.3.0", cuda: "12.1.1-base"} + - {latest: "false", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1", cuda: "12.1.1-base"} steps: - @@ -111,19 +117,26 @@ jobs: - name: Env Setter run: | - echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} + REPO=${GITHUB_REPOSITORY,,} + echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV} + echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV} - name: Checkout uses: actions/checkout@v3 - name: Permissions fixes run: | - reponame="$(basename ${GITHUB_REPOSITORY})" - target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/build/COPY*" chmod -R ug+rwX ${target} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -131,8 +144,8 @@ jobs: - name: Set tags run: | - img_path="ghcr.io/${{ env.PACKAGE_NAME }}" - + img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}" + img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cuda" if [[ -z '${{ matrix.build.tag }}' ]]; then WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')" else @@ -145,9 +158,12 @@ jobs: if [[ ${{ matrix.build.latest }} == "true" ]]; then echo "Marking latest" - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}, ${img_path}:${base_tag}, ${img_path}:latest, ${img_path}:latest-jupyter, ${img_path}:latest-cuda" + # GHCR.io Tags + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda" + # Docker.io Tags + TAGS="${TAGS}, ${img_path_dhub}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${base_tag}, ${img_path_dhub}:latest" else - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}" + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${base_tag}-${WEBUI_TAG}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - @@ -170,7 +186,7 @@ jobs: fail-fast: false matrix: build: - - {latest: "true", tag: "v1.9.4", python: "3.10", pytorch: "2.3.0", rocm: "6.0-core"} + - {latest: "false", tag: "v1.10.0", python: "3.10", pytorch: "2.3.1", rocm: "6.0-core"} steps: - name: Free Space @@ -186,19 +202,26 @@ jobs: - name: Env Setter run: | - echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} + REPO=${GITHUB_REPOSITORY,,} + echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV} + echo "REPO_NAME=${REPO#*/}" >> ${GITHUB_ENV} - name: Checkout uses: actions/checkout@v3 - name: Permissions fixes run: | - reponame="$(basename ${GITHUB_REPOSITORY})" - target="${HOME}/work/${reponame}/${reponame}/build/COPY*" + target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/build/COPY*" chmod -R ug+rwX ${target} + - + name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -206,8 +229,8 @@ jobs: - name: Set tags run: | - img_path="ghcr.io/${{ env.PACKAGE_NAME }}" - + img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}" + img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-rocm" if [[ -z '${{ matrix.build.tag }}' ]]; then WEBUI_TAG="$(curl -s https://api.github.com/repos/AUTOMATIC1111/stable-diffusion-webui/tags | jq -r '.[0].name')" else @@ -216,13 +239,16 @@ jobs: [ -z "$WEBUI_TAG" ] && { echo "Error: WEBUI_TAG is empty. Exiting script." >&2; exit 1; } echo "WEBUI_TAG=${WEBUI_TAG}" >> ${GITHUB_ENV} - base_tag="v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}" + base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}" if [[ ${{ matrix.build.latest }} == "true" ]]; then echo "Marking latest" - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}, ${img_path}:${base_tag}, ${img_path}:latest-rocm, ${img_path}:latest-rocm-jupyter" + # GHCR.io Tags + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm" + # Docker.io Tags + TAGS="${TAGS}, ${img_path_dhub}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${base_tag}, ${img_path_dhub}:latest" else - TAGS="${img_path}:${base_tag}-${WEBUI_TAG}" + TAGS="${img_path_ghcr}:${base_tag}-${WEBUI_TAG}, ${img_path_dhub}:${base_tag}-${WEBUI_TAG}" fi echo "TAGS=${TAGS}" >> ${GITHUB_ENV} - diff --git a/README.md b/README.md index 7555ab4..3b2f2d7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Run [Automatic1111 WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webu ## Documentation -All AI-Dock containers share a common base which is designed to make running on cloud services such as [vast.ai](https://link.ai-dock.org/vast.ai) and [runpod.io](https://link.ai-dock.org/template) as straightforward and user friendly as possible. +All AI-Dock containers share a common base which is designed to make running on cloud services such as [vast.ai](https://link.ai-dock.org/vast.ai) as straightforward and user friendly as possible. Common features and options are documented in the [base wiki](https://github.com/ai-dock/base-image/wiki) but any additional features unique to this image will be detailed below. @@ -23,7 +23,7 @@ Tags follow these patterns: ##### _CUDA_ - `:v2-cuda-[x.x.x]-[base|runtime]-[ubuntu-version]` -- `:latest-cuda` → `:v2-cuda-11.8.0-base-22.04` +- `:latest-cuda` → `:v2-cuda-12.1.1-base-22.04` ##### _ROCm_ - `:rocm-[x.x.x]-runtime-[ubuntu-version]` @@ -47,7 +47,7 @@ Supported Platforms: `NVIDIA CUDA`, `AMD ROCm`, `CPU` | ------------------------ | ----------- | | `AUTO_UPDATE` | Update A1111 Web UI on startup (default `false`) | | `WEBUI_BRANCH` | WebUI branch/commit hash for auto update. (default `master`) | -| `WEBUI_FLAGS` | Startup flags. eg. `--no-half --api` | +| `WEBUI_ARGS` | Startup arguments. eg. `--no-half --api` | | `WEBUI_PORT_HOST` | Web UI port (default `7860`) | | `WEBUI_URL` | Override `$DIRECT_ADDRESS:port` with URL for Web UI | @@ -70,16 +70,14 @@ The following services will be launched alongside the [default services](https:/ ### Stable Diffusion WebUI -The service will launch on port `7860` unless you have specified an override with `WEBUI_PORT`. +The service will launch on port `7860` unless you have specified an override with `WEBUI_PORT_HOST`. -WebUI will be updated to the latest version on container start. You can pin the version to a branch or commit hash by setting the `WEBUI_BRANCH` variable. +You can set startup arguments by using variable `WEBUI_ARGS`. -You can set startup flags by using variable `WEBUI_FLAGS`. - -To manage this service you can use `supervisorctl [start|stop|restart] webui`. +To manage this service you can use `supervisorctl [start|stop|restart] webui` or via the Service Portal application. >[!NOTE] ->All services are password protected by default. See the [security](https://github.com/ai-dock/base-image/wiki#security) and [environment variables](https://github.com/ai-dock/base-image/wiki/2.0-Environment-Variables) documentation for more information. +>All services are password protected by default and HTTPS is available optionally. See the [security](https://github.com/ai-dock/base-image/wiki#security) and [environment variables](https://github.com/ai-dock/base-image/wiki/2.0-Environment-Variables) documentation for more information. ## Pre-Configured Templates @@ -92,10 +90,4 @@ To manage this service you can use `supervisorctl [start|stop|restart] webui`. --- -**Runpod.​io** - -- [A1111 WebUI:latest](https://link.ai-dock.org/template-runpod-sd-webui) - ---- - _The author ([@robballantyne](https://github.com/robballantyne)) may be compensated if you sign up to services linked in this document. Testing multiple variants of GPU images in many different environments is both costly and time-consuming; This helps to offset costs_ \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh index 1bdf462..ab44e87 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/preflight.d/10-default.sh @@ -2,8 +2,13 @@ # This file will be sourced in init.sh function preflight_main() { + if [[ -n $WEBUI_FLAGS ]]; then + export WEBUI_ARGS="$WEBUI_FLAGS" + env-store WEBUI_ARGS + fi preflight_update_webui - printf "%s" "${WEBUI_FLAGS}" > /etc/a1111_webui_flags.conf + printf "%s" "${WEBUI_ARGS}" > /etc/a1111_webui_args.conf + ln -s /etc/a1111_webui_args.conf /etc/a1111_webui_flags.conf } function preflight_update_webui() { diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args new file mode 120000 index 0000000..89626f4 --- /dev/null +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args @@ -0,0 +1 @@ +set-webui-args.sh \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args.sh new file mode 100755 index 0000000..d53064f --- /dev/null +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-args.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "$@" > /etc/a1111_webui_args.conf +supervisorctl restart webui \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags new file mode 120000 index 0000000..6472e06 --- /dev/null +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags @@ -0,0 +1 @@ +set-webui-args \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh deleted file mode 100755 index 35fa0d0..0000000 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "$@" > /etc/a1111_webui_flags.conf -supervisorctl restart webui \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh new file mode 120000 index 0000000..6472e06 --- /dev/null +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/set-webui-flags.sh @@ -0,0 +1 @@ +set-webui-args \ No newline at end of file diff --git a/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-webui.sh b/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-webui.sh index c1af63c..e9134fa 100755 --- a/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-webui.sh +++ b/build/COPY_ROOT_1/opt/ai-dock/bin/supervisor-webui.sh @@ -41,12 +41,12 @@ function start() { printf "Starting $SERVICE_NAME...\n" - PLATFORM_FLAGS= + PLATFORM_ARGS= if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--use-cpu all --skip-torch-cuda-test --no-half" + PLATFORM_ARGS="--use-cpu all --skip-torch-cuda-test --no-half" fi # No longer skipping prepare-environment - BASE_FLAGS="" + BASE_ARGS="" # Delay launch until micromamba is ready if [[ -f /run/workspace_sync || -f /run/container_config ]]; then @@ -70,13 +70,13 @@ function start() { fuser -k -SIGKILL ${LISTEN_PORT}/tcp > /dev/null 2>&1 & wait -n - FLAGS_COMBINED="${PLATFORM_FLAGS} ${BASE_FLAGS} $(cat /etc/a1111_webui_flags.conf)" + ARGS_COMBINED="${PLATFORM_ARGS} ${BASE_ARGS} $(cat /etc/a1111_webui_args.conf)" printf "Starting %s...\n" "${SERVICE_NAME}" cd /opt/stable-diffusion-webui source "$WEBUI_VENV/bin/activate" LD_PRELOAD=libtcmalloc.so python launch.py \ - ${FLAGS_COMBINED} --port ${LISTEN_PORT} + ${ARGS_COMBINED} --port ${LISTEN_PORT} } start 2>&1 \ No newline at end of file diff --git a/config/provisioning/default-rocm.sh b/config/provisioning/default-rocm.sh index c824d99..21a2dfc 100755 --- a/config/provisioning/default-rocm.sh +++ b/config/provisioning/default-rocm.sh @@ -94,18 +94,18 @@ function provisioning_start() { "${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ "${ESRGAN_MODELS[@]}" - PLATFORM_FLAGS="" + PLATFORM_ARGS="" if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--use-cpu all --skip-torch-cuda-test --no-half" + PLATFORM_ARGS="--use-cpu all --skip-torch-cuda-test --no-half" fi - PROVISIONING_FLAGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" - FLAGS_COMBINED="${PLATFORM_FLAGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_FLAGS}" + PROVISIONING_ARGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" + ARGS_COMBINED="${PLATFORM_ARGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_ARGS}" # Start and exit because webui will probably require a restart cd /opt/stable-diffusion-webui && \ source $WEBUI_VENV/bin/activate LD_PRELOAD=libtcmalloc.so python launch.py \ - ${FLAGS_COMBINED} + ${ARGS_COMBINED} deactivate provisioning_print_end } diff --git a/config/provisioning/default.sh b/config/provisioning/default.sh index 8707714..3e0dc4b 100755 --- a/config/provisioning/default.sh +++ b/config/provisioning/default.sh @@ -95,18 +95,18 @@ function provisioning_start() { "${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ "${ESRGAN_MODELS[@]}" - PLATFORM_FLAGS="" + PLATFORM_ARGS="" if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--use-cpu all --skip-torch-cuda-test --no-half" + PLATFORM_ARGS="--use-cpu all --skip-torch-cuda-test --no-half" fi - PROVISIONING_FLAGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" - FLAGS_COMBINED="${PLATFORM_FLAGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_FLAGS}" + PROVISIONING_ARGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" + ARGS_COMBINED="${PLATFORM_ARGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_ARGS}" # Start and exit because webui will probably require a restart cd /opt/stable-diffusion-webui && \ source "$WEBUI_VENV/bin/activate" LD_PRELOAD=libtcmalloc.so python launch.py \ - ${FLAGS_COMBINED} + ${ARGS_COMBINED} deactivate provisioning_print_end } diff --git a/config/provisioning/newbase-rocm.sh b/config/provisioning/newbase-rocm.sh deleted file mode 100755 index c824d99..0000000 --- a/config/provisioning/newbase-rocm.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash -# This file will be sourced in init.sh -# Namespace functions with provisioning_ - -# https://raw.githubusercontent.com/ai-dock/stable-diffusion-webui/main/config/provisioning/default.sh - -### Edit the following arrays to suit your workflow - values must be quoted and separated by newlines or spaces. - -DISK_GB_REQUIRED=30 - -PIP_PACKAGES=( - -) - -EXTENSIONS=( - "https://github.com/Mikubill/sd-webui-controlnet" - "https://github.com/deforum-art/sd-webui-deforum" - "https://github.com/adieyal/sd-dynamic-prompts" - "https://github.com/ototadana/sd-face-editor" - "https://github.com/AlUlkesh/stable-diffusion-webui-images-browser" - "https://github.com/hako-mikan/sd-webui-regional-prompter" - "https://github.com/Coyote-A/ultimate-upscale-for-automatic1111" - "https://github.com/Gourieff/sd-webui-reactor" -) - -CHECKPOINT_MODELS=( - "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt" - #"https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.ckpt" - #"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors" - #"https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors" -) - -LORA_MODELS=( - #"https://civitai.com/api/download/models/16576" -) - -VAE_MODELS=( - "https://huggingface.co/stabilityai/sd-vae-ft-ema-original/resolve/main/vae-ft-ema-560000-ema-pruned.safetensors" - "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors" - "https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors" -) - -ESRGAN_MODELS=( - "https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth" - "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth" - "https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth" -) - -CONTROLNET_MODELS=( - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_canny-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_color-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_depth-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_keypose-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_openpose-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_seg-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_sketch-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_style-fp16.safetensors" -) - - -### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ### - -function provisioning_start() { - source /opt/ai-dock/etc/environment.sh - source /opt/ai-dock/bin/venv-set.sh webui - - DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED)) - provisioning_print_header - provisioning_get_pip_packages - provisioning_get_extensions - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/ckpt" \ - "${CHECKPOINT_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/lora" \ - "${LORA_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/controlnet" \ - "${CONTROLNET_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/vae" \ - "${VAE_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ - "${ESRGAN_MODELS[@]}" - - PLATFORM_FLAGS="" - if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--use-cpu all --skip-torch-cuda-test --no-half" - fi - PROVISIONING_FLAGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" - FLAGS_COMBINED="${PLATFORM_FLAGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_FLAGS}" - - # Start and exit because webui will probably require a restart - cd /opt/stable-diffusion-webui && \ - source $WEBUI_VENV/bin/activate - LD_PRELOAD=libtcmalloc.so python launch.py \ - ${FLAGS_COMBINED} - deactivate - provisioning_print_end -} - -function provisioning_get_pip_packages() { - if [[ -n $PIP_PACKAGES ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir ${PIP_PACKAGES[@]} - fi -} - -function provisioning_get_extensions() { - for repo in "${EXTENSIONS[@]}"; do - dir="${repo##*/}" - path="/opt/stable-diffusion-webui/extensions/${dir}" - requirements="${path}/requirements.txt" - if [[ -d $path ]]; then - if [[ ${AUTO_UPDATE,,} == "true" ]]; then - printf "Updating extension: %s...\n" "${repo}" - ( cd "$path" && git pull ) - fi - if [[ -e $requirements ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir -r "$requirements" - fi - else - printf "Downloading extension: %s...\n" "${repo}" - git clone "${repo}" "${path}" --recursive - if [[ -e $requirements ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir -r "${requirements}" - fi - fi - done -} - -function provisioning_get_models() { - if [[ -z $2 ]]; then return 1; fi - dir="$1" - mkdir -p "$dir" - shift - if [[ $DISK_GB_ALLOCATED -ge $DISK_GB_REQUIRED ]]; then - arr=("$@") - else - printf "WARNING: Low disk space allocation - Only the first model will be downloaded!\n" - arr=("$1") - fi - - printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" - for url in "${arr[@]}"; do - printf "Downloading: %s\n" "${url}" - provisioning_download "${url}" "${dir}" - printf "\n" - done -} - -function provisioning_print_header() { - printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n" - if [[ $DISK_GB_ALLOCATED -lt $DISK_GB_REQUIRED ]]; then - printf "WARNING: Your allocated disk size (%sGB) is below the recommended %sGB - Some models will not be downloaded\n" "$DISK_GB_ALLOCATED" "$DISK_GB_REQUIRED" - fi -} - -function provisioning_print_end() { - printf "\nProvisioning complete: Web UI will start now\n\n" -} - -# Download from $1 URL to $2 file path -function provisioning_download() { - wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1" -} - -provisioning_start \ No newline at end of file diff --git a/config/provisioning/newbase.sh b/config/provisioning/newbase.sh deleted file mode 100755 index 8707714..0000000 --- a/config/provisioning/newbase.sh +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/bash -# This file will be sourced in init.sh -# Namespace functions with provisioning_ - -# https://raw.githubusercontent.com/ai-dock/stable-diffusion-webui/main/config/provisioning/default.sh - -### Edit the following arrays to suit your workflow - values must be quoted and separated by newlines or spaces. - -DISK_GB_REQUIRED=30 - -PIP_PACKAGES=( - -) - -EXTENSIONS=( - "https://github.com/Mikubill/sd-webui-controlnet" - "https://github.com/d8ahazard/sd_dreambooth_extension" - "https://github.com/deforum-art/sd-webui-deforum" - "https://github.com/adieyal/sd-dynamic-prompts" - "https://github.com/ototadana/sd-face-editor" - "https://github.com/AlUlkesh/stable-diffusion-webui-images-browser" - "https://github.com/hako-mikan/sd-webui-regional-prompter" - "https://github.com/Coyote-A/ultimate-upscale-for-automatic1111" - "https://github.com/Gourieff/sd-webui-reactor" -) - -CHECKPOINT_MODELS=( - "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt" - #"https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.ckpt" - #"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors" - #"https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors" -) - -LORA_MODELS=( - #"https://civitai.com/api/download/models/16576" -) - -VAE_MODELS=( - "https://huggingface.co/stabilityai/sd-vae-ft-ema-original/resolve/main/vae-ft-ema-560000-ema-pruned.safetensors" - "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors" - "https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors" -) - -ESRGAN_MODELS=( - "https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth" - "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth" - "https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth" -) - -CONTROLNET_MODELS=( - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_canny-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_color-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_depth-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_keypose-fp16.safetensors" - "https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_openpose-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_seg-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_sketch-fp16.safetensors" - #"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/t2iadapter_style-fp16.safetensors" -) - - -### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ### - -function provisioning_start() { - source /opt/ai-dock/etc/environment.sh - source /opt/ai-dock/bin/venv-set.sh webui - - DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED)) - provisioning_print_header - provisioning_get_pip_packages - provisioning_get_extensions - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/ckpt" \ - "${CHECKPOINT_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/lora" \ - "${LORA_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/controlnet" \ - "${CONTROLNET_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/vae" \ - "${VAE_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ - "${ESRGAN_MODELS[@]}" - - PLATFORM_FLAGS="" - if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_FLAGS="--use-cpu all --skip-torch-cuda-test --no-half" - fi - PROVISIONING_FLAGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" - FLAGS_COMBINED="${PLATFORM_FLAGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_FLAGS}" - - # Start and exit because webui will probably require a restart - cd /opt/stable-diffusion-webui && \ - source "$WEBUI_VENV/bin/activate" - LD_PRELOAD=libtcmalloc.so python launch.py \ - ${FLAGS_COMBINED} - deactivate - provisioning_print_end -} - -function provisioning_get_pip_packages() { - if [[ -n $PIP_PACKAGES ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir ${PIP_PACKAGES[@]} - fi -} - -function provisioning_get_extensions() { - for repo in "${EXTENSIONS[@]}"; do - dir="${repo##*/}" - path="/opt/stable-diffusion-webui/extensions/${dir}" - requirements="${path}/requirements.txt" - if [[ -d $path ]]; then - # Pull only if AUTO_UPDATE - if [[ ${AUTO_UPDATE,,} == "true" ]]; then - printf "Updating extension: %s...\n" "${repo}" - ( cd "$path" && git pull ) - fi - # Always pip install - if [[ -e $requirements ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir -r "$requirements" - fi - else - printf "Downloading extension: %s...\n" "${repo}" - git clone "${repo}" "${path}" --recursive - if [[ -e $requirements ]]; then - "$WEBUI_VENV_PIP" install --no-cache-dir -r "${requirements}" - fi - fi - done -} - -function provisioning_get_models() { - if [[ -z $2 ]]; then return 1; fi - dir="$1" - mkdir -p "$dir" - shift - if [[ $DISK_GB_ALLOCATED -ge $DISK_GB_REQUIRED ]]; then - arr=("$@") - else - printf "WARNING: Low disk space allocation - Only the first model will be downloaded!\n" - arr=("$1") - fi - - printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" - for url in "${arr[@]}"; do - printf "Downloading: %s\n" "${url}" - provisioning_download "${url}" "${dir}" - printf "\n" - done -} - -function provisioning_print_header() { - printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n" - if [[ $DISK_GB_ALLOCATED -lt $DISK_GB_REQUIRED ]]; then - printf "WARNING: Your allocated disk size (%sGB) is below the recommended %sGB - Some models will not be downloaded\n" "$DISK_GB_ALLOCATED" "$DISK_GB_REQUIRED" - fi -} - -function provisioning_print_end() { - printf "\nProvisioning complete: Web UI will start now\n\n" -} - -# Download from $1 URL to $2 file path -function provisioning_download() { - wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1" -} - -provisioning_start \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 8ace163..00fa4d7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -60,7 +60,7 @@ services: - SERVICEPORTAL_METRICS_PORT=${SERVICEPORTAL_METRICS_PORT:-21111} - SERVICEPORTAL_URL=${SERVICEPORTAL_URL:-} - WEBUI_BRANCH=${WEBUI_BRANCH:-} - - WEBUI_FLAGS=${WEBUI_FLAGS:-} + - WEBUI_ARGS=${WEBUI_ARGS:-} - WEBUI_PORT_HOST=${WEBUI_PORT_HOST:-7860} - WEBUI_PORT_LOCAL=${WEBUI_PORT_LOCAL:-17860} - WEBUI_METRICS_PORT=${WEBUI_METRICS_PORT:-27860}