Skip to content

Instantly share code, notes, and snippets.

@BloodBlight
Forked from In-line/Dockerfile
Last active October 19, 2023 16:12
Show Gist options
  • Save BloodBlight/0d36b33d215056395f34db26fb419a63 to your computer and use it in GitHub Desktop.
Save BloodBlight/0d36b33d215056395f34db26fb419a63 to your computer and use it in GitHub Desktop.
AMD 7900 XTX Stable Diffusion Web UI docker container (ROCM 5.6)

Make a spot and go there:

mkdir -p ~/SD
cd ~/SD

Put the dockerfile and docker-compose.yml here.

Your on your own on that. ;)

Build the image:

docker build -t sd-mrocm-5-6 .

Start it up!

docker-compose up -d

Now watch the logs to see it do it's thing, will take a while the first time:

docker logs -f sd-mrocm-5-6

Usually finished after the "lve/main/config.json" file is DLed.

In the future, you can just run this to re-start it:

docker start sd-mrocm-5-6

It's now running as a service, browse to: http://127.0.0.1:7860

NOTES

The web UI will pull things in the background and may act... Odd the first few times you run things. WAIT for a while after a click, watch your GUI and network load to see what's up. Sometimes just hitting F5 to reload the page will fix things.

version: "3.9"
services:
sd:
image: sd-mrocm-5-6
container_name: sd-mrocm-5-6
ports:
- "7860:7860"
volumes:
- ./models:/SD/stable-diffusion-webui/models/
- ./repositories:/SD/stable-diffusion-webui/repositories/
- ./extensions:/SD/stable-diffusion-webui/extensions/
- ./outputs:/SD/stable-diffusion-webui/outputs/
devices:
- '/dev/kfd:/dev/kfd'
- '/dev/dri:/dev/dri'
security_opt:
- seccomp:unconfined
group_add:
- video
#docker run -ti rocm/composable_kernel:ck_ub20.04_rocm5.6 bash
FROM rocm/composable_kernel:ck_ub20.04_rocm5.6
RUN mkdir /SD
# Clone SD
WORKDIR /SD
RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
WORKDIR /SD/stable-diffusion-webui
RUN git reset --hard 22bcc7be428c94e9408f589966c2040187245d81
RUN apt update && apt install -y python3.8-venv
RUN python3 -m venv venv
# Activate VENV
ENV VIRTUAL_ENV=/SD/stable-diffusion-webui/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m pip install --upgrade pip wheel
ENV HIP_VISIBLE_DEVICES=0
ENV PYTORCH_ROCM_ARCH="gfx1100"
ENV CMAKE_PREFIX_PATH=/SD/stable-diffusion-webui/venv/
ENV USE_CUDA=0
# Remove old torch and torchvision
RUN pip uninstall -y torch torchvision
# pytorch
RUN pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.5
WORKDIR /SD/stable-diffusion-webui
# Patch requirements.txt to remove torch
RUN sed '/torch/d' requirements.txt
RUN pip install -r requirements.txt
EXPOSE 7860/tcp
# Fix for "detected dubious ownership in repository" by rom1win.
RUN git config --global --add safe.directory '*'
CMD python3 launch.py --listen --disable-safe-unpickle --skip-torch-cuda-test
@SebaLenny
Copy link

Unfortunately I get 😭
Error response from daemon: error gathering device information while adding custom device "/dev/kfd": no such file or directory

@BloodBlight
Copy link
Author

BloodBlight commented Oct 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment