Hassle free AUTOMATIC1111 stable-diffusion-webui docker imagefor AMD RX5700XT Navi10
5.2K
I struggled a lot to have AUTOMATIC1111 WebUI implementation for Stable Diffusion locally on my AMD RX5700XT. I decide to build this image to be able to run it hassle free just with a single command. Everything is already cofigured, you've just to place your models in the mapped folder.
This image is based on:
rocm/pytorch:rocm5.2_ubuntu20.04_py3.7_pytorch_1.11.0_navi21
and on the github repository:
https://github.com/AUTOMATIC1111/stable-diffusion-webui
To use your own authentication username and password adjust accordingly the environment variables WEBUI_USER and WEBUI_PASSWORD in the docker-compose.yml file and issue this commands:
sudo docker compose up -d
P.S.: if you have more than one GPU you can user the environment variable HIP_VISIBLE_DEVICES
Otherwise just run:
sudo docker compose up -d
default user: admin
default password: ThisIsMySuperSecurePassword.123
running the compose command without sudo does not allow docker daemon to correctly manage the GPU
Dockerfile:
FROM rocm/pytorch:rocm5.2_ubuntu20.04_py3.7_pytorch_1.11.0_navi21
WORKDIR /dockerx/stable-diffusion-webui
RUN apt update && apt full-upgrade -y && apt install -y bc google-perftools && apt autoclean -y
RUN conda update conda
RUN conda create -y --name sd python=3.10.6
RUN conda install -y -n sd -c conda-forge libstdcxx-ng=12.1.0 --no-deps
RUN conda install -y -n sd -c conda-forge insightface=0.7.3 --no-deps
RUN conda init bash && . ~/.bashrc && echo "conda activate sd" >> ~/.bashrc
RUN rm -rf /dockerx/stable-diffusion-webui
RUN cd /dockerx && git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui && cd stable-diffusion-webui && git checkout tags/v1.10.0
RUN conda run --no-capture-output -n sd pip cache purge
ADD run.sh .
RUN chmod +x run.sh
ENTRYPOINT ["./run.sh"]
Docker compose file docker-compose.yml:
name: stable
services:
diffusion:
build: .
stdin_open: true
restart: always
tty: true
privileged: true
environment:
WEBUI_USER: "admin"
WEBUI_PASSWORD: "ThisIsMySuperSecurePassword.123"
HIP_VISIBLE_DEVICES: "0"
devices:
- /dev/kfd
- /dev/dri
group_add:
- video
ipc: host
cap_add:
- SYS_PTRACE
security_opt:
- seccomp=unconfined
volumes:
- ./models:/dockerx/stable-diffusion-webui/models
- ./extensions:/dockerx/stable-diffusion-webui/extensions
ports:
- 7860:7860
healthcheck:
test: curl --fail http://localhost:7860/sdapi/v1/options || exit 1
interval: 30s
timeout: 30s
retries: 3
start_period: 240s
run.sh file:
#!/bin/bash -x
if [ -n "$COMMANDLINE_ARGS" ]; then
echo "export COMMANDLINE_ARGS=\"$COMMANDLINE_ARGS\"" >> /dockerx/stable-diffusion-webui/webui-user.sh
else
echo 'export COMMANDLINE_ARGS="--listen --device-id=0 --precision full --no-half --medvram --skip-version-check --api --gradio-auth-path auth --enable-insecure-extension-access --opt-sub-quad-attention"' >> /dockerx/stable-diffusion-webui/webui-user.sh
fi
if [ -n "$WEBUI_USER" ] && [ -n "$WEBUI_PASSWORD" ]; then
echo "$WEBUI_USER:$WEBUI_PASSWORD" > /dockerx/stable-diffusion-webui/auth
else
echo 'admin:ThisIsMySuperSecurePassword.123' > /dockerx/stable-diffusion-webui/auth
fi
echo 'export TORCH_COMMAND="pip install https://repo.radeon.com/rocm/manylinux/.private-9bd8754a636553e1d1ce3e107bf18c00/20231018/torch-2.1.0%2Brocm5.2-cp310-cp310-linux_x86_64.whl https://github.com/kmsedu/pytorch_rocm52_wheels/raw/main/torchvision-0.17.0a0+rocm5.2-cp310-cp310-linux_x86_64.whl"' >> /dockerx/stable-diffusion-webui/webui-user.sh
mv /dockerx/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/lib/libMIOpen.so /dockerx/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/lib/libMIOpen.so_ORIG
cp /opt/rocm/lib/libMIOpen.so.1.0.50200.nvv5.ms1 /dockerx/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/lib/libMIOpen.so
sed -i 's|^can_run_as_root.*|can_run_as_root=1|g' /dockerx/stable-diffusion-webui/webui.sh
conda run --no-capture-output -n sd ./webui.sh
This docker compose file will build the image for you if placed in the same path of the Dockerfile, otherwise you can comment the build line and uncomment the image line like this:
#build: .
image: moophlo/stable-diffusion:latest
Content type
Image
Digest
sha256:5beb6d65a…
Size
22 GB
Last updated
over 1 year ago
docker pull moophlo/stable-diffusion