From 7f3b6e72406963a93aac5b09e87d52854515c1f8 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Mon, 19 Aug 2024 19:59:16 -0400 Subject: [PATCH] create deployment for stable-diffusion-webui-forge --- docker-compose.yaml | 27 +++++++++++ shared/embeddings/.gitignore | 2 + shared/lora/.gitignore | 2 + shared/tensors/.gitignore | 2 + shared/vae/.gitignore | 2 + stable-diffusion-webui-forge/Dockerfile | 45 +++++++++++++++++++ .../extensions/.gitignore | 2 + .../favorites/.gitignore | 2 + .../outputs/.gitignore | 2 + .../repositories/.gitignore | 2 + 10 files changed, 88 insertions(+) create mode 100644 docker-compose.yaml create mode 100644 shared/embeddings/.gitignore create mode 100644 shared/lora/.gitignore create mode 100644 shared/tensors/.gitignore create mode 100644 shared/vae/.gitignore create mode 100644 stable-diffusion-webui-forge/Dockerfile create mode 100644 stable-diffusion-webui-forge/extensions/.gitignore create mode 100644 stable-diffusion-webui-forge/favorites/.gitignore create mode 100644 stable-diffusion-webui-forge/outputs/.gitignore create mode 100644 stable-diffusion-webui-forge/repositories/.gitignore diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d3009ed --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,27 @@ +services: + stable-diffusion-webui-forge: + build: ./stable-diffusion-webui-forge + restart: unless-stopped + environment: + - HSA_OVERRIDE_GFX_VERSION=11.0.0 + ports: + - 7860:7860 + devices: + - /dev/kfd + - /dev/dri + volumes: + - ./shared/lora:/app/models/Lora + - ./shared/tensors:/app/models/Stable-diffusion + - ./shared/vae/:/app/models/VAE + - ./shared/embeddings:/app/embeddings + - ./stable-diffusion-webui-forge/extensions:/app/extensions + - ./stable-diffusion-webui-forge/repositories:/app/repositories + - ./stable-diffusion-webui-forge/outputs:/app/outputs + - ./stable-diffusion-webui-forge/favorites:/app/log/images + group_add: + - video + ipc: host + cap_add: + - SYS_PTRACE + security_opt: + - seccomp=unconfined diff --git a/shared/embeddings/.gitignore b/shared/embeddings/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/shared/embeddings/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/shared/lora/.gitignore b/shared/lora/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/shared/lora/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/shared/tensors/.gitignore b/shared/tensors/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/shared/tensors/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/shared/vae/.gitignore b/shared/vae/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/shared/vae/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/stable-diffusion-webui-forge/Dockerfile b/stable-diffusion-webui-forge/Dockerfile new file mode 100644 index 0000000..d3f6ff7 --- /dev/null +++ b/stable-diffusion-webui-forge/Dockerfile @@ -0,0 +1,45 @@ +ARG PYTHON_VERSION=3.10 +ARG ROCM_VERSION=6.1 + +# we do not use rocm/pytorch as it currently use python 3.7 and we require >=python 3.10 +FROM rocm/rocm-terminal:${ROCM_VERSION} +ARG PYTHON_VERSION +ARG ROCM_VERSION + +# switch to root for setup +USER root + +RUN git clone https://github.com/lllyasviel/stable-diffusion-webui-forge /app +WORKDIR /app +RUN apt update \ + && apt upgrade -y \ + && apt install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt update \ + && apt install -y pciutils bc mesa-utils google-perftools \ + && apt install -y python${PYTHON_VERSION}-full \ + && curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \ + && chown -R 1000:1000 /app \ + && rm -rf /var/lib/apt/lists/* + +# switch back to unpreviledged user +USER 1000 + +RUN python${PYTHON_VERSION} -m venv /app/env \ + && sed -i'' -Ee "s/rocm[0-9]\.[0-9]/rocm${ROCM_VERSION}/g" webui.sh \ + && /app/env/bin/python -m pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm${ROCM_VERSION} \ + && /app/env/bin/python -m pip install --no-cache-dir -r requirements_versions.txt + +VOLUME ["/app/models/Lora", "/app/models/Stable-diffusion", "/app/models/VAE"] +VOLUME ["/app/embeddings"] +VOLUME ["/app/extensions"] +VOLUME ["/app/repositories"] +VOLUME ["/app/outputs"] +VOLUME ["/app/log/images"] + +EXPOSE 7860 +ENV python_cmd=/app/env/bin/python +ENV PYTORCH_CUDA_ALLOC_CONF="garbage_collection_threshold:0.9,max_split_size_mb:512" +ENV COMMANDLINE_ARGS="--listen --enable-insecure-extension-access --theme=dark --api --update-check" +ENTRYPOINT ["./webui.sh"] +CMD [] \ No newline at end of file diff --git a/stable-diffusion-webui-forge/extensions/.gitignore b/stable-diffusion-webui-forge/extensions/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/stable-diffusion-webui-forge/extensions/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/stable-diffusion-webui-forge/favorites/.gitignore b/stable-diffusion-webui-forge/favorites/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/stable-diffusion-webui-forge/favorites/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/stable-diffusion-webui-forge/outputs/.gitignore b/stable-diffusion-webui-forge/outputs/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/stable-diffusion-webui-forge/outputs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/stable-diffusion-webui-forge/repositories/.gitignore b/stable-diffusion-webui-forge/repositories/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/stable-diffusion-webui-forge/repositories/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file