Last active
March 15, 2024 06:52
-
-
Save geerlingguy/ff3c3cbcf4416be2c0c1e0f836a8183d to your computer and use it in GitHub Desktop.
Install Stable Diffusion on an AMD GPU PC running Ubuntu 20.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: This will only work on Navi21 GPUs (6800/6900+). | |
# See: https://github.com/RadeonOpenCompute/ROCm/issues/1668#issuecomment-1043994570 | |
# Install Conda (latest from https://docs.conda.io/en/latest/miniconda.html#linux-installers) | |
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh | |
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh | |
# follow the prompts to install it, and run `conda` to make sure it's working. | |
# Install git and curl, and clone the stable-diffusion repo | |
sudo apt install -y git curl | |
cd Downloads | |
git clone https://github.com/CompVis/stable-diffusion.git | |
# Install dependencies and activate environment | |
cd stable-diffusion | |
conda env create -f environment.yaml | |
conda activate ldm | |
# Download Stable Diffusion weights | |
curl https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media > sd-v1-4.ckpt | |
# Symlink the weights into place | |
mkdir -p models/ldm/stable-diffusion-v1/ | |
ln -s -r sd-v1-4.ckpt models/ldm/stable-diffusion-v1/model.ckpt | |
# Install AMD ROCm support | |
wget https://repo.radeon.com/amdgpu-install/22.10/ubuntu/focal/amdgpu-install_22.10.50100-1_all.deb | |
sudo apt-get install ./amdgpu-install_22.10.50100-1_all.deb | |
sudo amdgpu-install --usecase=dkms,graphics,rocm,lrt,hip,hiplibsdk | |
# make sure you see your GPU by running rocm-smi | |
# Make AMD GPU work with ROCm | |
cd stable-diffusion/ | |
conda remove cudatoolkit -y | |
pip3 uninstall torch torchvision -y | |
# Install PyTorch ROCm | |
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.1.0 | |
pip3 install transformers==4.19.2 scann kornia==0.6.4 torchmetrics==0.6.0 | |
# Generate an image | |
python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms |
Please change the file extension from .txt
to .sh
. It's a shell script, and GitHub will add syntax highlighting based on the extension.
Hi there, thanks for this toutorial.
I have a RIG and I want to try execute stable difusion inside the rig (with x8 AMD 6700xt)
GPU Temp AvgPwr SCLK MCLK Fan Perf PwrCap VRAM% GPU%
0 29.0c 29.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 1 30.0c 29.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 2 31.0c 29.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 3 28.0c 28.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 4 31.0c 29.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 5 28.0c 28.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 6 31.0c 28.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0% 7 30.0c 30.0W 1450Mhz 1074Mhz 77.65% manual 211.0W 0% 0%
After follow your instructions, it show me an unexplain error that says "Killed"
(ldm) root@Adam:~/amd/stable-diffusion# python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms Global seed set to 42 Loading model from models/ldm/stable-diffusion-v1/model.ckpt Global Step: 470000 LatentDiffusion: Running in eps-prediction mode Killed
I have 8GB of RAM.
thanks,
8GB of RAM? aahaahahaaa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for this. When I run the final python code to generate the image I get the following errors...
just wondered if you have any pointers on this?
Update
This was caused by the weights link not working, switching to curl
https://f004.backblazeb2.com/file/aai-blog-files/sd-v1-4.ckpt > sd-v1-4.ckpt
fixes it