runpod-workers / worker-a1111

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

automatic1111 1.5.0 build error #9

Closed metter closed 1 year ago

metter commented 1 year ago

I am trying to build this container with the latest a1111 version. I changed the commit hash to the latest commit in the Dockerfile here:

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

and here

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

But during build, when cache.py is called, I get this error:

ERROR [stage-1 16/29] RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors                                            6.2s ------                                                                                                                                                              
 > [stage-1 16/29] RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors:                                                       
#31 4.810 Warning: Stable Diffusion XL not found at path /stable-diffusion-webui/repositories/generative-models/sgm                                                 
#31 5.375 No module 'xformers'. Proceeding without it.                                                                                                              
#31 5.383 Warning: caught exception 'Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx', memory monitor disabled                                                                                                                    
#31 5.561 Traceback (most recent call last):
#31 5.561   File "/stable-diffusion-webui/cache.py", line 1, in <module>
#31 5.561     from webui import initialize
#31 5.561   File "/stable-diffusion-webui/webui.py", line 61, in <module>
#31 5.561     from modules import shared, sd_samplers, upscaler, extensions, localization, ui_tempdir, ui_extra_networks, config_states
#31 5.561   File "/stable-diffusion-webui/modules/sd_samplers.py", line 1, in <module>
#31 5.561     from modules import sd_samplers_compvis, sd_samplers_kdiffusion, shared
#31 5.561   File "/stable-diffusion-webui/modules/sd_samplers_compvis.py", line 9, in <module>
#31 5.561     from modules import sd_samplers_common, prompt_parser, shared
#31 5.561   File "/stable-diffusion-webui/modules/sd_samplers_common.py", line 5, in <module>
#31 5.561     from modules import devices, processing, images, sd_vae_approx, sd_samplers, sd_vae_taesd
#31 5.561   File "/stable-diffusion-webui/modules/processing.py", line 16, in <module>
#31 5.561     import modules.sd_hijack
#31 5.561   File "/stable-diffusion-webui/modules/sd_hijack.py", line 5, in <module>
#31 5.561     import modules.textual_inversion.textual_inversion
#31 5.561   File "/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 16, in <module>
#31 5.561     from modules import shared, devices, sd_hijack, processing, sd_models, images, sd_samplers, sd_hijack_checkpoint, errors, hashes
#31 5.561   File "/stable-diffusion-webui/modules/sd_models.py", line 17, in <module>
#31 5.561     from modules import paths, shared, modelloader, devices, script_callbacks, sd_vae, sd_disable_initialization, errors, hashes, sd_models_config, sd_unet, sd_models_xl
#31 5.561   File "/stable-diffusion-webui/modules/sd_models_config.py", line 9, in <module>
#31 5.561     sd_xl_repo_configs_path = os.path.join(paths.paths['Stable Diffusion XL'], "configs", "inference")
#31 5.561 KeyError: 'Stable Diffusion XL'
------
executor failed running [/bin/bash -o pipefail -c cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors]: exit code: 1

I tried running the build without using cache.py, but that doesnt start a1111 in the endpoint. What exactly is cache.py doing and how do I need to adapt the steps so it works with 1.5.0 of automatic1111?

This is my current 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 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 && \
    . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git 5b3af030dd83e0297272d861c19477735d0317ec && \
    . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2486589f24165c8e3b303f84e9dbbea318df83e8

# RUN wget -O model.safetensors https://civitai.com/api/download/models/15236 
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 && ls -la

# ---------------------------------------------------------------------------- #
#                        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 68f336bd994bed5442ad95bad6b6ad5564a5409a && \
    pip install -r requirements_versions.txt

COPY --from=download /repositories/ ${ROOT}/repositories/
COPY --from=download /download/model.safetensors /model.safetensors
#COPY sd_xl_base_1.0.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

#1.5.0
ARG SHA=68f336bd994bed5442ad95bad6b6ad5564a5409a 
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 .

WORKDIR /repositories
RUN git clone https://github.com/Stability-AI/generative-models.git

WORKDIR /

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

WORKDIR /extensions
RUN git clone https://github.com/Mikubill/sd-webui-controlnet.git
RUN git clone https://github.com/Extraltodeus/multi-subject-render.git

WORKDIR /

# Copy the models and embeddings directories from the host to the container
COPY test_input.json /
COPY test_input_vanilla.json /
COPY models/Lora /stable-diffusion-webui/models/Lora
COPY models/ControlNet /stable-diffusion-webui/models/ControlNet
COPY models/openpose /stable-diffusion-webui/models/openpose
COPY embeddings /stable-diffusion-webui/embeddings

# 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
iosebyte commented 1 year ago

Hi! I have had the same problem, and I think I have a solution:

In dockerfile, I added the following line after the previous clone command (In Stage 1, line 21 in your dockerfile): RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models.git 45c443b316737a4ab6e40413d7794a7f5657c19f

metter commented 1 year ago

Hi! I have had the same problem, and I think I have a solution:

In dockerfile, I added the following line after the previous clone command (In Stage 1, line 21 in your dockerfile): RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models.git 45c443b316737a4ab6e40413d7794a7f5657c19f

Thank you. Yes, I had it figured out in the meantime :-)