Open kstenerud opened 1 year ago
So after some digging, it's caused by some inter-package breakage that occurred within the past two weeks. I got it to work by manually fixing up some package versions.
# Preinstall dependencies. This will fail
RUN python -d launch.py --exit --skip-torch-cuda-test || true
# Make fixes
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install torchmetrics==0.11.4 && \
pip3 install gradio>=3.36.1 && \
pip3 install fastapi==0.95.2 && \
true
# Preinstall dependencies again
RUN python -d launch.py --exit --skip-torch-cuda-test
Note: You can also move the model downloading part to your Dockerfile:
# Pre-download model
RUN wget -q https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors -O /sd/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
That gives a docker instance with a first-time launch of less than 30 seconds.
Everything working a-ok now :) Thanks for putting this out there!
BTW, the main stable-diffusion-webui branch now works with ROCM if you just make a one-line change: https://github.com/kstenerud/stable-diffusion-webui/commit/a08711d713bfeb2155f084b7d9f9a28ce6f3ac43
Then you can get a fully-functional SD webui like so:
FROM ubuntu:jammy
SHELL ["/bin/bash", "-c"]
ENV PORT=7860 \
DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
REQS_FILE='requirements.txt' \
COMMANDLINE_ARGS=''
WORKDIR /opt
RUN apt-get -y update && \
apt-get install -y --no-install-recommends libstdc++-12-dev ca-certificates wget gnupg2 gawk curl git libglib2.0-0 apt-utils python3.10-venv python3-pip && \
wget https://repo.radeon.com/amdgpu-install/5.5/ubuntu/jammy/amdgpu-install_5.5.50500-1_all.deb && \
apt-get install -y ./amdgpu-install_5.5.50500-1_all.deb && \
amdgpu-install -y --usecase=rocm --no-dkms && \
true
RUN git clone -b rocm https://github.com/kstenerud/stable-diffusion-webui.git /sd
WORKDIR /sd
RUN apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* && \
python3 -m venv venv && \
source venv/bin/activate && \
ln -s /usr/bin/python3 /usr/bin/python && \
python3 -m pip install --upgrade pip wheel
# Pre-download model
RUN wget -q https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors -O /sd/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
# Preinstall dependencies. This will fail.
RUN python -d launch.py --exit --skip-torch-cuda-test || true
# Apply fixes
# pytorch_lightning: No module named 'pytorch_lightning.utilities.distributed'
# torchmetrics: cannot import name '_compare_version' from 'torchmetrics.utilities.imports
# fastapi: AttributeError: __config__
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install pytorch_lightning==1.7.5 && \
pip3 install torchmetrics==0.11.4 && \
pip3 install fastapi==0.95.2 && \
true
# SD output image format problem: SyntaxError: not a TIFF file (header b"b'Exif\\x" not valid)
# Just run the previous output image through another image editor and it'll work again.
# Preinstall dependencies again
RUN python -d launch.py --exit --skip-torch-cuda-test
EXPOSE ${PORT}
VOLUME [ "/sd/configs","/sd/models", "/sd/outputs","/sd/extensions", "/sd/plugins"]
ENTRYPOINT python -d launch.py --port "${PORT}" --listen || bash
Describe the bug
Attempting to run the docker image results in:
To Reproduce Steps to reproduce the behavior:
docker build . -t stable-diffusion-rocm
docker run -it -p 7860:7860 --device=/dev/kfd --device=/dev/dri --group-add=video --ipc=host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /home/karl/stable-diffusion:/pwd -e HSA_OVERRIDE_GFX_VERSION=10.3.0 --name stable-diffusion stable-diffusion-rocm
Expected behavior
It should complete initialization.
Container Output
Desktop (please complete the following information):