ClashSAN 2023-02-27 22:16:35 +00:00
parent ccead75a62
commit c6d75545e3

@ -125,4 +125,88 @@ TORCH_COMMAND='pip install torch torchvision --extra-index-url https://download.
It's possible that you don't need "--precision full", dropping "--no-half" however it may not work for everyone.
Certain cards like the Radeon RX 6000 Series and the RX 500 Series will function normally without the option `--precision full --no-half`, saving plenty of vram. (noted [here](https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/5468).)
Always use this new launch-command from now on, also when restarting the web UI in following runs.
Always use this new launch-command from now on, also when restarting the web UI in following runs.
# Install on AMD and Arch Linux
**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](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies#required-dependencies) and install `pip`
```bash
sudo pacman -S python-pip
```
2. 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`:
```bash
# Install either one:
sudo pacman -S python-pytorch-rocm
sudo pacman -S python-pytorch-opt-rocm # AVX2 CPUs only
```
3. Install `torchvision` with ROCm backend
`python-torchvision-rocm` package is located in AUR. Clone the git repository and compile the package on your machine
```bash
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](https://wiki.archlinux.org/title/AUR_helpers).
## 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
```bash
python -m venv venv --system-site-packages
source venv/bin/activate
pip install -r requirements.txt
```
2. 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:
```bash
#!/bin/bash
python launch.py #add arguments here
```
Depending on the GPU model, you may need to add certain [Command Line Arguments](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings) and [Optimizations](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Optimizations) for webui to run properly. Also refer to the [Automatic Installation](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs#automatic-installation) section for AMD GPUs.
3. Make the script executable and run webui (first start may take a bit longer)
```bash
sudo chmod +x ./webui-py.sh
./webui-py.sh
```
## Launch
Run the following inside the project root to start webui:
```bash
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](https://github.com/rocm-arch/python-torchvision-rocm/blob/b66f7ed9540a0e25f4a81bf0d9cfc3d76bc0270e/PKGBUILD#L68-L74) and [PyTorch](https://github.com/archlinux/svntogit-community/blob/5689e7f44f082ba3c37724c2890e93e7106002a1/trunk/PKGBUILD#L220). References for architectures can be found [here](https://llvm.org/docs/AMDGPUUsage.html#processors). If not, consider building both packages locally or use another [installation method](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs).
- 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*