How to Use Stable Diffusion on Windows 10 with an AMD GPU
This guide records the setup I used in September 2022 for Stable Diffusion 1.4 on Windows 10 with an AMD Vega 56. The package versions and model access flow are historical, so check the linked projects for current instructions before starting.
ROCm did not work with Windows Subsystem for Linux on my machine. Linux users should use a current ROCm-specific guide instead.
Video version
Hardware and software
An AMD GPU with at least 8 GB of VRAM is a practical baseline for this setup. Lower-memory cards may fail or produce gray images.
Install a recent Python 3 release and confirm that both python and pip are available in PATH. I used Python 3.10.2:
> python --version
Python 3.10.2You also need a Hugging Face account, access to the Stable Diffusion 1.4 model, and an API token from the Hugging Face settings.
Install the DirectML Diffusers branch
Open Windows Terminal or Command Prompt as an administrator. Clone Harish Anand's DirectML branch of Diffusers, then install its dependencies:
git clone https://github.com/harishanand95/diffusers.git
cd diffusers && git checkout dml && pip install -e .
pip install transformers ftfy scipyThis setup depends on a nightly DirectML build of ONNX Runtime. Download the wheel from the ORT Nightly package feed and choose the file matching your Python version.
For Python 3.10.2, I used:
pip install ort_nightly_directml-1.13.0.dev20220901005-cp310-cp310-win_amd64.whlRun the command from the directory containing the wheel. In this setup, using a Windows path avoided the resolution problem I encountered with ./ort_....
Export the model to ONNX
Move to the inference examples and authenticate with Hugging Face:
cd ./diffusers/examples/inference
huggingface-cli loginPaste the API token when prompted. If authentication succeeds but the model download fails, open the Stable Diffusion 1.4 model page and accept its terms.
Export the model:
python ./save_onnx.pyGenerate an image
The dml_onnx.py example generates images through DirectML. Its final section contains the prompt, seed, output filename, step count, and guidance scale.
When changing the output resolution, choose width and height values divisible by eight. The script's instructions also require exporting an ONNX model for the new resolution.
This image took roughly two minutes and thirty seconds on my AMD Vega 56:

The original video remains available on my YouTube channel. You can also buy me a coffee if the archived setup helped.