runpod-workers / worker-a1111

Automatic1111 serverless worker.
MIT License
75 stars 109 forks source link

wont work with latest commit #14

Closed metter closed 1 year ago

metter commented 1 year ago

When updating the Dockerfile to A1111 1.6.0 here

ARG SHA=5ef669de080814067961f28357256e8fe27544f4
RUN --mount=type=cache,target=/root/.cache/pip \
    cd stable-diffusion-webui && \
    git fetch && \
    git reset --hard ${SHA} && \
    pip install -r requirements_versions.txt

I get this error during build:

 => ERROR [stage-1 14/16] RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors                                                                                              4.5s
------
 > [stage-1 14/16] RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors:
3.550 Warning: Stable Diffusion XL not found at path /stable-diffusion-webui/repositories/generative-models/sgm
3.905 Traceback (most recent call last):
3.905   File "/stable-diffusion-webui/cache.py", line 1, in <module>
3.905     from webui import initialize
3.905   File "/stable-diffusion-webui/webui.py", line 13, in <module>
3.905     initialize.imports()
3.905   File "/stable-diffusion-webui/modules/initialize.py", line 30, in imports
3.905     import sgm.modules.encoders.modules  # noqa: F401
3.905 ModuleNotFoundError: No module named 'sgm'
------
Dockerfile:78
--------------------
  76 |     
  77 |     COPY builder/cache.py /stable-diffusion-webui/cache.py
  78 | >>> RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors
  79 |     
  80 |     # Cleanup section (Worker Template)
--------------------
ERROR: failed to solve: process "/bin/bash -o pipefail -c cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors" did not complete successfully: exit code: 1

This is my Dockerfile:

# ---------------------------------------------------------------------------- #
#                         Stage 1: Download the models                         #
# ---------------------------------------------------------------------------- #
FROM alpine/git:2.36.2 as download

COPY builder/clone.sh /clone.sh

# Clone the repos and clean unnecessary files
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 && \
    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 && \
    . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 5b3af030dd83e0297272d861c19477735d0317ec && \
    . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2486589f24165c8e3b303f84e9dbbea318df83e8

WORKDIR /download
RUN wget -O model.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors 
RUN wget -O sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors 

# ---------------------------------------------------------------------------- #
#                        Stage 3: Build the final image                        #
# ---------------------------------------------------------------------------- #
FROM python:3.10.9-slim

ENV DEBIAN_FRONTEND=noninteractive \
    PIP_PREFER_BINARY=1 \
    LD_PRELOAD=libtcmalloc.so \
    ROOT=/stable-diffusion-webui \
    PYTHONUNBUFFERED=1

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update && \
    apt install -y \
    fonts-dejavu-core rsync git jq moreutils aria2 wget libgoogle-perftools-dev procps && \
    apt-get autoremove -y && rm -rf /var/lib/apt/lists/* && apt-get clean -y

RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip \
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

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 5ef669de080814067961f28357256e8fe27544f4 && \
    pip install -r requirements_versions.txt

COPY --from=download /repositories/ ${ROOT}/repositories/
COPY --from=download /download/model.safetensors /model.safetensors
RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/data/* ${ROOT}/interrogate
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r ${ROOT}/repositories/CodeFormer/requirements.txt

# Install Python dependencies (Worker Template)
COPY builder/requirements.txt /requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install --upgrade pip && \
    pip install --upgrade -r /requirements.txt --no-cache-dir && \
    rm /requirements.txt

ARG SHA=5ef669de080814067961f28357256e8fe27544f4
RUN --mount=type=cache,target=/root/.cache/pip \
    cd stable-diffusion-webui && \
    git fetch && \
    git reset --hard ${SHA} && \
    pip install -r requirements_versions.txt

ADD src .

COPY builder/cache.py /stable-diffusion-webui/cache.py
RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors

# Cleanup section (Worker Template)
RUN apt-get autoremove -y && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

RUN chmod +x /start.sh
CMD /start.sh
justinmerrell commented 1 year ago

5ef669de080814067961f28357256e8fe27544f4 is 1.6.0

Successfully built https://github.com/runpod-workers/worker-a1111/actions/runs/6279098545

kilimchoi commented 1 year ago

@justinmerrell on line 72, you reset it to older commit hash that's not 1.6. Also I don't think you need to redo the whole thing from lines 68 to 73.

or if you change line 68 to 5ef669de080814067961f28357256e8fe27544f4 you can reproduce the error.

justinmerrell commented 1 year ago

Ah, good catch, can't believe I missed that 🤦

I'll get that updated and debug where it's getting held up.