├── demo.py ├── README.md ├── Dockerfile ├── anything-v3.0 └── Dockerfile ├── ROCm-3.5.1 └── Dockerfile ├── ROCm-3.5.1+anything-v3.0 └── Dockerfile └── webui └── Dockerfile /demo.py: -------------------------------------------------------------------------------- 1 | # Source: https://huggingface.co/Linaqruf/anything-v3.0 2 | from datetime import datetime 3 | from diffusers import StableDiffusionPipeline 4 | import torch 5 | import pathlib 6 | 7 | def gen_img(prompt: str="pikachu", negative_prompt: str="", count: int=1): 8 | model_id = "Linaqruf/anything-v3.0" 9 | pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda") 10 | 11 | # Disables NSFW filtering; grow up and don't be a crybaby about some potentially naughty content ;) 12 | # Also, this filter seems to be somewhat aggressive when it comes to false alarms. 13 | pipe.safety_checker = lambda images, **kwargs: (images, False) 14 | images = pipe(prompt, negative_prompt=negative_prompt).images 15 | 16 | output_path = "/data/stable-diffusion/out" 17 | pathlib.Path(output_path).mkdir(parents=True, exist_ok=True) 18 | datetime_str = datetime.now().strftime("%d.%m.%Y_%H:%M:%S") 19 | for i, img in enumerate(images): 20 | p = prompt.replace(" ", "_") 21 | img.save(f"${output_path}/{datetime_str}___{p}___{i:04d}.png") 22 | 23 | gen_img() 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pytorch on gfx803-based GPUs 2 | 3 | This was created in order to be able to use Stable Diffusion on my RX590 with ROCm hardware acceleration. 4 | 5 | This was only tested with Arch Linux. WSL most likely won't work. 6 | 7 | After building this image, you can run it with 8 | 9 | ``` 10 | docker run -it -v $HOME:/data --privileged --rm --device=/dev/kfd --device=/dev/dri --group-add video 11 | ``` 12 | 13 | where `` should be printed by `docker build .` after finishing to run in this directory. 14 | 15 | **Note:** My screen goes dark when running this on my system directly. However, it works when used through an SSH 16 | connection, at least after killing the X server and switching to a TTY. 17 | This seems to be due to an issue with ROCm >4.0, which doesn't officially support gfx803 cards anymore. 18 | Unfortunately, the older 3.5 version provided by @xuhuisheng doesn't appear to work for Stable Diffusion (I'd be glad to be proven wrong, however). 19 | 20 | - **Update**: As it turned out, there were 2 other reasons: 21 | 22 | 1. I had a bug (as in, a litteral insect) stuck in my power connector 23 | 2. My PC was overheating - as it turned out, my PC fans suck and didn't push enough air 24 | 25 | After adressing both of these, it worked for the most part. 26 | 27 | - **Final update** 28 | 29 | I decided to just get a new GPU, an RTX 2060 12 GB. Even that one runs *waaay* faster than my RX 590, and it does so without issues. For that reason, I cannot maintain this repo (feel free to fork it). You may also consider a Tesla P40, which will probably cost you about the same if you buy it used, and, from what I've read, seems to provide performance comparable to an RTX 3090 (though keep in mind that a lot of the cheap ones were used for crypto mining, as well as the other caviats that come with using a Tesla GPU in your PC). 30 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | # Change into home directory of the root user 4 | WORKDIR /root 5 | 6 | # Update the base image 7 | RUN apt-get update 8 | RUN apt-get upgrade -y 9 | 10 | # Install base dependencies 11 | ENV DEBIAN_FRONTEND=noninteractive 12 | ENV TZ=Etc/UTC 13 | RUN apt-get install -y wget git python3 python-is-python3 python3-venv tzdata 14 | 15 | # Install ROCm 16 | RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 17 | RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb 18 | RUN rm -f amdgpu-install_5.3.50300-1_all.deb 19 | RUN yes | amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk 20 | RUN apt-get install -y libopenmpi-dev miopen-hip libopenblas-dev 21 | RUN ln -s libroctx64.so /opt/rocm/lib/libroctx64.so.1 22 | RUN ln -s libroctracer64.so /opt/rocm/lib/libroctracer64.so.1 23 | 24 | # Create a python virtual environment 25 | RUN mkdir stable-diffusion 26 | RUN cd stable-diffusion 27 | ENV VIRTUAL_ENV=/root/venv 28 | RUN python -m venv $VIRTUAL_ENV 29 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 30 | RUN bash -c 'source ./venv/bin/activate; python -m pip install --upgrade pip wheel' 31 | 32 | # Install torch and stable diffusion 33 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/hsa-rocr_1.7.0.50300-63.20.04_amd64.deb 34 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/rocblas_2.45.0.50300-63.20.04_amd64.deb 35 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl 36 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 37 | RUN apt-get install --allow-downgrades -y ./hsa-rocr_1.7.0.50300-63.20.04_amd64.deb ./rocblas_2.45.0.50300-63.20.04_amd64.deb 38 | RUN yes | python -m pip install --upgrade pip wheel 39 | RUN yes | python -m pip install diffusers huggingface-hub transformers accelerate 40 | RUN yes | python -m pip install torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 41 | ENV LD_LIBRARY_PATH=/opt/rocm/lib 42 | 43 | # Final clean up 44 | RUN rm -f hsa-rocr_1.7.0.50300-63.20.04_amd64.deb rocblas_2.45.0.50300-63.20.04_amd64.deb torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 45 | -------------------------------------------------------------------------------- /anything-v3.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | # Change into home directory of the root user 4 | WORKDIR /root 5 | 6 | # Update the base image 7 | RUN apt-get update 8 | RUN apt-get upgrade -y 9 | 10 | # Install base dependencies 11 | ENV DEBIAN_FRONTEND=noninteractive 12 | ENV TZ=Etc/UTC 13 | RUN apt-get install -y wget git python3 python-is-python3 python3-venv tzdata 14 | 15 | # Install ROCm 16 | RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 17 | RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb 18 | RUN rm -f amdgpu-install_5.3.50300-1_all.deb 19 | RUN yes | amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk 20 | RUN apt-get install -y libopenmpi-dev miopen-hip libopenblas-dev 21 | RUN ln -s libroctx64.so /opt/rocm/lib/libroctx64.so.1 22 | RUN ln -s libroctracer64.so /opt/rocm/lib/libroctracer64.so.1 23 | 24 | # Create a python virtual environment 25 | RUN mkdir stable-diffusion 26 | RUN cd stable-diffusion 27 | ENV VIRTUAL_ENV=/root/venv 28 | RUN python -m venv $VIRTUAL_ENV 29 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 30 | RUN bash -c 'source ./venv/bin/activate; python -m pip install --upgrade pip wheel' 31 | 32 | # Install torch and stable diffusion 33 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/hsa-rocr_1.7.0.50300-63.20.04_amd64.deb 34 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/rocblas_2.45.0.50300-63.20.04_amd64.deb 35 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl 36 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 37 | RUN apt-get install --allow-downgrades -y ./hsa-rocr_1.7.0.50300-63.20.04_amd64.deb ./rocblas_2.45.0.50300-63.20.04_amd64.deb 38 | RUN yes | python -m pip install --upgrade pip wheel 39 | RUN yes | python -m pip install diffusers huggingface-hub transformers accelerate 40 | RUN yes | python -m pip install torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 41 | ENV LD_LIBRARY_PATH=/opt/rocm/lib 42 | 43 | # Download anything-v3.0, embedding it into the image 44 | RUN python -c 'from diffusers import StableDiffusionPipeline; import torch; model_id = "Linaqruf/anything-v3.0"; pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)' 45 | 46 | # Final clean up 47 | RUN rm -f hsa-rocr_1.7.0.50300-63.20.04_amd64.deb rocblas_2.45.0.50300-63.20.04_amd64.deb torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 48 | -------------------------------------------------------------------------------- /ROCm-3.5.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | # Change into home directory of the root user 4 | WORKDIR /root 5 | 6 | # Update the base image 7 | RUN apt-get update 8 | RUN apt-get upgrade -y 9 | RUN apt-get dist-upgrade -y 10 | 11 | # Install base dependencies 12 | ENV DEBIAN_FRONTEND=noninteractive 13 | ENV TZ=Etc/UTC 14 | RUN apt-get install -y wget git python3 python-is-python3 python3-venv tzdata gnupg linux-headers-5.4.0-54-generic libnuma-dev 15 | 16 | # Install ROCm 17 | ###RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 18 | ###RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb 19 | ###RUN rm -f amdgpu-install_5.3.50300-1_all.deb 20 | ###RUN yes | amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk 21 | ###RUN apt-get install -y libopenmpi-dev miopen-hip libopenblas-dev 22 | ###RUN ln -s libroctx64.so /opt/rocm/lib/libroctx64.so.1 23 | ###RUN ln -s libroctracer64.so /opt/rocm/lib/libroctracer64.so.1 24 | #RUN echo 'APT { Get { AllowUnauthenticated "1"; }; };' >> /etc/apt/apt.conf # The official signature key seems to have expired :/ 25 | #RUN wget -q -O - 'http://repo.radeon.com/rocm/apt/3.5.1/rocm.gpg.key' | apt-key add - 26 | RUN wget -q -O - 'https://repo.radeon.com/rocm/rocm.gpg.key' | apt-key add - 27 | RUN echo 'deb [arch=amd64] http://repo.radeon.com/rocm/apt/3.5.1/ xenial main' | tee /etc/apt/sources.list.d/rocm.list 28 | RUN apt-get update 29 | #RUN apt-get install -y amdgpu-dkms rocm-core amdgpu-core amdgpu-lib amdgpu-lib32 rocm-dev rocm-language-runtime rocm-hip-runtime rocm-hip-sdk libopenmpi-dev miopen-hip libopenblas-dev rocm-libs 30 | RUN apt-get install -y rocm-dkms libopenmpi-dev miopen-hip libopenblas-dev rocm-libs rccl 31 | RUN echo 'export PATH="${PATH}:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin"' >> /etc/profile.d/rocm.sh 32 | ENV PATH="${PATH}:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin" 33 | RUN ldconfig 34 | 35 | # Create a python virtual environment 36 | RUN mkdir stable-diffusion 37 | RUN cd stable-diffusion 38 | ENV VIRTUAL_ENV=/root/venv 39 | RUN python -m venv $VIRTUAL_ENV 40 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 41 | RUN bash -c 'source ./venv/bin/activate; python -m pip install --upgrade pip wheel' 42 | 43 | # Install torch and stable diffusion 44 | ENV LB_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/rocm/hip/lib:/opt/rocm/lib" 45 | RUN wget 'https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm35/torch-1.7.0a0-cp38-cp38-linux_x86_64.whl' 46 | RUN wget 'https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm35/torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl' 47 | RUN yes | python -m pip install --upgrade pip wheel 48 | RUN yes | python -m pip install diffusers huggingface-hub transformers accelerate 49 | RUN yes | python -m pip install torch-1.7.0a0-cp38-cp38-linux_x86_64.whl torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl 50 | 51 | # Final clean up 52 | RUN rm -f torch-1.7.0a0-cp38-cp38-linux_x86_64.whl torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl 53 | -------------------------------------------------------------------------------- /ROCm-3.5.1+anything-v3.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | # Change into home directory of the root user 4 | WORKDIR /root 5 | 6 | # Update the base image 7 | RUN apt-get update 8 | RUN apt-get upgrade -y 9 | RUN apt-get dist-upgrade -y 10 | 11 | # Install base dependencies 12 | ENV DEBIAN_FRONTEND=noninteractive 13 | ENV TZ=Etc/UTC 14 | RUN apt-get install -y wget git python3 python-is-python3 python3-venv tzdata gnupg linux-headers-5.4.0-54-generic libnuma-dev 15 | 16 | # Install ROCm 17 | ###RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 18 | ###RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb 19 | ###RUN rm -f amdgpu-install_5.3.50300-1_all.deb 20 | ###RUN yes | amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk 21 | ###RUN apt-get install -y libopenmpi-dev miopen-hip libopenblas-dev 22 | ###RUN ln -s libroctx64.so /opt/rocm/lib/libroctx64.so.1 23 | ###RUN ln -s libroctracer64.so /opt/rocm/lib/libroctracer64.so.1 24 | #RUN echo 'APT { Get { AllowUnauthenticated "1"; }; };' >> /etc/apt/apt.conf # The official signature key seems to have expired :/ 25 | #RUN wget -q -O - 'http://repo.radeon.com/rocm/apt/3.5.1/rocm.gpg.key' | apt-key add - 26 | RUN wget -q -O - 'https://repo.radeon.com/rocm/rocm.gpg.key' | apt-key add - 27 | RUN echo 'deb [arch=amd64] http://repo.radeon.com/rocm/apt/3.5.1/ xenial main' | tee /etc/apt/sources.list.d/rocm.list 28 | RUN apt-get update 29 | #RUN apt-get install -y amdgpu-dkms rocm-core amdgpu-core amdgpu-lib amdgpu-lib32 rocm-dev rocm-language-runtime rocm-hip-runtime rocm-hip-sdk libopenmpi-dev miopen-hip libopenblas-dev rocm-libs 30 | RUN apt-get install -y rocm-dkms libopenmpi-dev miopen-hip libopenblas-dev rocm-libs rccl 31 | RUN echo 'export PATH="${PATH}:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin"' >> /etc/profile.d/rocm.sh 32 | ENV PATH="${PATH}:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin" 33 | RUN ldconfig 34 | 35 | # Create a python virtual environment 36 | RUN mkdir stable-diffusion 37 | RUN cd stable-diffusion 38 | ENV VIRTUAL_ENV=/root/venv 39 | RUN python -m venv $VIRTUAL_ENV 40 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 41 | RUN bash -c 'source ./venv/bin/activate; python -m pip install --upgrade pip wheel' 42 | 43 | # Install torch and stable diffusion 44 | ENV LB_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/rocm/hip/lib:/opt/rocm/lib" 45 | RUN wget 'https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm35/torch-1.7.0a0-cp38-cp38-linux_x86_64.whl' 46 | RUN wget 'https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm35/torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl' 47 | RUN yes | python -m pip install --upgrade pip wheel 48 | RUN yes | python -m pip install diffusers huggingface-hub transformers accelerate 49 | RUN yes | python -m pip install torch-1.7.0a0-cp38-cp38-linux_x86_64.whl torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl 50 | 51 | # Download anything-v3.0, embedding it into the image 52 | RUN python -c 'from diffusers import StableDiffusionPipeline; import torch; model_id = "Linaqruf/anything-v3.0"; pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)' 53 | 54 | # Final clean up 55 | RUN rm -f torch-1.7.0a0-cp38-cp38-linux_x86_64.whl torchvision-0.8.0a0+2f40a48-cp38-cp38-linux_x86_64.whl 56 | -------------------------------------------------------------------------------- /webui/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | ##ARG -it 4 | #ARG -v $HOME:/data 5 | ##ARG --rm 6 | #ARG --privileged 7 | #ARG --device=/dev/kfd 8 | #ARG --device=/dev/dri 9 | #ARG --group-add video 10 | #ARG -p 7860:7860 11 | ARG -v $HOME:/data --privileged --rm --device=/dev/kfd --device=/dev/dri --group-add video -p 7860:7860 12 | 13 | # Change into home directory of the root user 14 | WORKDIR /root 15 | 16 | # Update the base image 17 | RUN apt-get update 18 | RUN apt-get upgrade -y 19 | 20 | # Install base dependencies 21 | # DEBIAN_FRONTEND=noninteractive 22 | ENV DEBIAN_FRONTEND="noninteractive" 23 | ENV TZ="Etc/UTC" 24 | RUN echo 'export TZ="Etc/UTC"' >> /root/.bashrc 25 | RUN apt-get install -y wget git python3 python-is-python3 python3-venv tzdata libjpeg-dev 26 | 27 | # Install ROCm 28 | RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 29 | RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb 30 | RUN rm -f amdgpu-install_5.3.50300-1_all.deb 31 | RUN apt-get update 32 | RUN yes | amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk 33 | RUN apt-get update 34 | RUN apt-get install -y libopenmpi-dev libopenblas-dev miopen-hip 35 | RUN ln -s libroctx64.so /opt/rocm/lib/libroctx64.so.1 36 | RUN ln -s libroctracer64.so /opt/rocm/lib/libroctracer64.so.1 37 | 38 | # Install PyTorch and AUTOMATIC1111/stable-diffusion-webui 39 | RUN mkdir -p /root/stable-diffusion 40 | RUN cd /root/stable-diffusion 41 | 42 | ## Create a python virtual environment 43 | RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /root/stable-diffusion/stable-diffusion-webui 44 | ENV VIRTUAL_ENV="/root/stable-diffusion/stable-diffusion-webui/venv" 45 | RUN echo 'export VIRTUAL_ENV="/root/stable-diffusion/stable-diffusion-webui/venv"' >> /root/.bashrc 46 | RUN python -m venv $VIRTUAL_ENV 47 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 48 | RUN echo 'export PATH="$VIRTUAL_ENV/bin:$PATH"' >> /root/.bashrc 49 | RUN bash -c 'source "$VIRTUAL_ENV/bin/activate"; python -m pip install --upgrade pip wheel' 50 | RUN echo 'source "$VIRTUAL_ENV/bin/activate"' >> /root/.bashrc 51 | 52 | ## Install PyTorch and dependencies 53 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/hsa-rocr_1.7.0.50300-63.20.04_amd64.deb 54 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm530/rocblas_2.45.0.50300-63.20.04_amd64.deb 55 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl 56 | RUN wget https://github.com/xuhuisheng/rocm-gfx803/releases/download/rocm500/torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 57 | RUN apt-get install --allow-downgrades -y ./hsa-rocr_1.7.0.50300-63.20.04_amd64.deb ./rocblas_2.45.0.50300-63.20.04_amd64.deb 58 | RUN yes | python -m pip install --upgrade pip wheel 59 | RUN yes | python -m pip install diffusers 60 | RUN yes | python -m pip install huggingface-hub 61 | RUN yes | python -m pip install transformers 62 | RUN yes | python -m pip install accelerate 63 | RUN yes | python -m pip install gfpgan 64 | RUN yes | python -m pip install clip 65 | RUN yes | python -m pip install open_clip_torch 66 | 67 | RUN git clone "https://github.com/Stability-AI/stablediffusion.git" "/root/stable-diffusion/stable-diffusion-webui/repositories/stable-diffusion-stability-ai" 68 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/stable-diffusion-stability-ai; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/stable-diffusion-stability-ai fetch' 69 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/stable-diffusion-stability-ai; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/stable-diffusion-stability-ai checkout 47b6b607fdd31875c9279cd2f4f16b92e4ea958e' 70 | 71 | RUN git clone "https://github.com/CompVis/taming-transformers.git" "/root/stable-diffusion/stable-diffusion-webui/repositories/taming-transformers" 72 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/taming-transformers; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/taming-transformers fetch' 73 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/taming-transformers; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/taming-transformers checkout 24268930bf1dce879235a7fddd0b2355b84d7ea6' 74 | 75 | RUN git clone "https://github.com/crowsonkb/k-diffusion.git" "/root/stable-diffusion/stable-diffusion-webui/repositories/k-diffusion" 76 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/k-diffusion; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/k-diffusion fetch' 77 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/k-diffusion; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/k-diffusion checkout 5b3af030dd83e0297272d861c19477735d0317ec' 78 | 79 | RUN git clone "https://github.com/sczhou/CodeFormer.git" "/root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer" 80 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer fetch' 81 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer checkout c5b4593074ba6214284d6acd5f1719b6c5d739af' 82 | 83 | RUN git clone "https://github.com/salesforce/BLIP.git" "/root/stable-diffusion/stable-diffusion-webui/repositories/BLIP" 84 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/BLIP; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/BLIP fetch' 85 | RUN bash -c 'cd /root/stable-diffusion/stable-diffusion-webui/repositories/BLIP; git -C /root/stable-diffusion/stable-diffusion-webui/repositories/BLIP checkout 48211a1594f1321b00f14c9f7a5b4813144b2fb9' 86 | 87 | #RUN yes | python -m pip install cython 88 | #RUN yes | python -m pip install pycocotools 89 | RUN yes | python -m pip install -r /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer/requirements.txt 90 | RUN yes | python -m pip install -r /root/stable-diffusion/stable-diffusion-webui/requirements.txt 91 | #RUN yes | python -m pip install xformers 92 | ### These packages need to be installed with the same command or it won't work 93 | ### (because installing torchvision would uninstall torch and install the stock 94 | ### verion from pypi instead). 95 | RUN yes | python -m pip install --force-reinstall torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 96 | ENV LD_LIBRARY_PATH="/opt/rocm/lib" 97 | RUN echo 'export LD_LIBRARY_PATH="/opt/rocm/lib"' >> /root/.bashrc 98 | RUN wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -O /root/stable-diffusion/stable-diffusion-webui/model.ckpt 99 | 100 | # TODO: Provide a model at /root/stable-diffusion/stable-diffusion-webui/model.ckpt 101 | 102 | RUN useradd sd -d /root/stable-diffusion 103 | RUN chown -R sd:sd /root/stable-diffusion 104 | RUN chmod 755 /root 105 | 106 | #RUN sudo -u sd env LD_LIBRARY_PATH="/opt/rocm/lib" bash -c 'cd ~/stable-diffusion-webui; source venv/bin/activate; ./webui.sh --skip-torch-cuda-test; true' 107 | RUN sudo -u sd env LD_LIBRARY_PATH="/opt/rocm/lib" bash -c 'cd ~/stable-diffusion-webui; source venv/bin/activate; python -c "import webui; webui.initialize()"; true' # This will error out - but that's fine, so we ignore it. 108 | RUN sudo -u sd bash -c "cd ~/stable-diffusion-webui; sed 's|^IS_HIGH_VERSION = |IS_HIGH_VERSION = False # |' -i repositories/CodeFormer/facelib/detection/yolov5face/face_detector.py" 109 | 110 | # TODO: Patch /root/stable-diffusion/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/yolov5face/face_detector.py 111 | # to force `IS_HIGH_VERSION` = False (it will try to parse the torch version, 1.11.0a0, into three integers otherwise, which won't work 112 | # because "0a0" is not an int). 113 | # We cannot do this right now, because it is only cloned when actually running CodeFormer 114 | 115 | # Final clean up 116 | #RUN rm -f hsa-rocr_1.7.0.50300-63.20.04_amd64.deb rocblas_2.45.0.50300-63.20.04_amd64.deb torch-1.11.0a0+git503a092-cp38-cp38-linux_x86_64.whl torchvision-0.12.0a0+2662797-cp38-cp38-linux_x86_64.whl 117 | 118 | EXPOSE 7860/tcp 119 | EXPOSE 7860/udp 120 | 121 | # You can run it with on command: 122 | #sudo -u sd env LD_LIBRARY_PATH="/opt/rocm/lib" bash -c 'cd ~/stable-diffusion-webui; source venv/bin/activate; ./webui.sh --disable-safe-unpickle --listen --medvram' 123 | --------------------------------------------------------------------------------