Install on AMD and Arch Linux - linwownil/stable-diffusion-webui GitHub Wiki

Install webui on Arch Linux with Arch-specific packages
and possibly other Arch-based Linux distributions (tested Feb 22 2023)

Arch-specific dependencies

  1. Start with required dependencies and install pip
sudo pacman -S python-pip
  1. Install pytorch with ROCm backend

Arch [Community] repository offers two pytorch packages, python-pytorch-rocm and python-pytorch-opt-rocm. For CPUs with AVX2 instruction set support, that is, CPU microarchitectures beyond Haswell (Intel, 2013) or Excavator (AMD, 2015), install python-pytorch-opt-rocm to benefit from performance optimizations. Otherwise install python-pytorch-rocm:

# Install either one:
sudo pacman -S python-pytorch-rocm
sudo pacman -S python-pytorch-opt-rocm   # AVX2 CPUs only
  1. Install torchvision with ROCm backend

python-torchvision-rocm package is located in AUR. Clone the git repository and compile the package on your machine

git clone https://aur.archlinux.org/python-torchvision-rocm.git
cd python-torchvision-rocm
makepkg -si

Confirm all steps until Pacman finishes installing python-torchvision-rocm.

Alternatively, install the python-torchvision-rocm package with a AUR helper.

Setup venv environment

  1. Manually create a venv environment with system site-packages (this will allows access to system pytorch and torchvision). Install the remaining Python dependencies
python -m venv venv --system-site-packages
source venv/bin/activate
pip install -r requirements.txt
  1. Create webui launch script

The Python launcher for webui needs to be run directly. In the project folder, create a new file called webui-py.sh and paste the following code:

#!/bin/bash
python launch.py #add arguments here

Depending on the GPU model, you may need to add certain Command Line Arguments and Optimizations for webui to run properly. Also refer to the Automatic Installation section for AMD GPUs.

  1. Make the script executable and run webui (first start may take a bit longer)
sudo chmod +x ./webui-py.sh
./webui-py.sh

Launch

Run the following inside the project root to start webui:

source venv/bin/activate
./webui-py.sh

Limitations

  • GPU model has to be supported by Arch dependencies

See if your GPU is listed as a build architecture in PYTORCH_ROCM_ARCH variable for Tourchvision and PyTorch. References for architectures can be found here. If not, consider building both packages locally or use another installation method.

  • Arch dependencies (pytorch, torchvision) are kept up-to-date by full system updates (pacman -Syu) and compiling, which may not be desirable when dependency combinations with fixed versions are wished

This guide has been tested on AMD Radeon RX6800 with Python 3.10.9, ROCm 5.4.3, PyTorch 1.13.1, Torchvision 0.14.1