Skip to content

Instantly share code, notes, and snippets.

@NoXPhasma
Last active June 21, 2024 16:51
Show Gist options
  • Save NoXPhasma/ba42b615c0ed1cb0c2b3a4a1b359ccf7 to your computer and use it in GitHub Desktop.
Save NoXPhasma/ba42b615c0ed1cb0c2b3a4a1b359ccf7 to your computer and use it in GitHub Desktop.
Install stable-diffusion-webui with ROCm support on Linux

Install stable-diffusion-webui with ROCm support on Arch Linux

First time installation:

  1. Clone and switch to the stable-diffusion-webui folder
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
  1. Create a new python environment and switch to it
python -m venv venv
source venv/bin/activate
  1. Update pip and wheel
python -m pip install --upgrade pip wheel
  1. To prevent a memory leak in the application, we need to preload /usr/lib/libtcmalloc.so, this is part of the gperftools package. So let's install that:
sudo pacman -S gperftools
  1. Create and edit a new shell file which we will use to start stable-diffusion-webui
touch start.sh
nano start.sh
  1. Add this content to the file and save it with CTRL+O and exit with CTRL+X
#!/usr/bin/env bash
source venv/bin/activate
export HSA_OVERRIDE_GFX_VERSION=10.3.0
export MIOPEN_DEBUG_COMGR_HIP_PCH_ENFORCE=0
export PYTORCH_HIP_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512
export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512
export TORCH_COMMAND='pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm5.7'
export REQS_FILE='requirements.txt'
export LD_PRELOAD=/usr/lib/libtcmalloc.so
python launch.py --precision full --no-half --enable-insecure-extension-access --listen --opt-sub-quad-attention --no-half-vae --disable-nan-check --medvram
  1. Make the file executable
chmod +x start.sh
  1. Deactivate the python environment
deactivate

Running stable-diffusion-webui

Switch to the stable-diffusion-webui folder and run:

./start.sh
@NoXPhasma
Copy link
Author

@kallestrop You'll need to use python3.10 to create the python environment in step 2:

/path/to/python3.10 -m venv venv

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