Friday, August 22, 2025

The Ultimate Guide: Taming Stable Diffusion on an AMD RX 580

So, you have a trusty AMD RX 580 graphics card and you want to dive into the world of local AI image generation with Stable Diffusion. You've seen the incredible results online, but the internet seems to think you need a high-end NVIDIA card.

The good news? It is absolutely possible to get the powerful Automatic1111 Web UI running on your RX 580. The bad news? The path is riddled with cryptic errors and frustrating setbacks.

This guide is a chronicle of a real-world troubleshooting session. It's not just a "how-to"—it's a "how-to-fix-it-when-it-inevitably-breaks" manual. We will walk through the entire process, from installation to conquering every single error we encountered along the way.

Part 1: The Foundation - Getting the Prerequisites Right

Before we even think about Stable Diffusion, we need a solid foundation. Getting this part wrong will cause everything else to fail.

  1. Python 3.10.6: Version is critical. Do not use a newer version. Download the specific "Windows installer (64-bit)" for Python 3.10.6. During installation, you must check the box that says "Add Python 3.10 to PATH". This is non-negotiable.

  2. Git for Windows: This tool allows us to download the necessary software from its repository. Download and install it, accepting all the default options.

Part 2: The Installation - The "Happy Path"

This is how the installation is supposed to go.

  1. Create a Folder: Create a simple, clean directory for your installation, for example, C:\Stable-Diffusion.

  2. Clone the Repository: Open the Command Prompt (cmd) and navigate to your folder (cd C:\Stable-Diffusion). Then, run the following command to download the special AMD-compatible version of the Web UI:

    Cmd
    git clone https://github.com/lshqqytiger/stable-diffusion-webui-directml
  3. Download a Model: You need a "checkpoint" model to generate images. Start with the standard Stable Diffusion 1.5 model. Download the v1-5-pruned-emaonly.safetensors file and place it in:
    C:\Stable-Diffusion\stable-diffusion-webui-directml\models\Stable-diffusion

Part 3: The First Launch & The Inevitable Errors

This is where reality sets in. We will now configure the launch file and systematically crush every error that appears.

Navigate to your stable-diffusion-webui-directml folder and locate the webui-user.bat file. This is the key to our setup. We will be editing and running this file repeatedly.

Error #1: RuntimeError: Torch is not able to use GPU

This is the first error everyone hits. The software is looking for an NVIDIA (CUDA) GPU and can't find one.

The Fix:

  1. Right-click webui-user.bat and select Edit.

  2. Find the line set COMMANDLINE_ARGS=.

  3. Add the --skip-torch-cuda-test flag. The line should now look like this:
    set COMMANDLINE_ARGS=--skip-torch-cuda-test

  4. Save the file and run webui-user.bat again.

Error #2: AttributeError: module 'torch._C' has no attribute '_CudaDeviceProperties'

You fixed the first error, but now a deeper part of the program is still trying to call NVIDIA-specific code. This happens because the automatic installer has downloaded the wrong version of PyTorch, the core machine-learning library.

The Definitive Fix (Manual Environment Setup):
The automatic installer is failing, so we'll do its job for it. This is the most critical part of the guide.

  1. Delete the Broken Environment: In your stable-diffusion-webui-directml folder, delete the entire . This removes all the incorrectly installed packages.

  2. Open Command Prompt: Open a new cmd window and navigate to your installation folder:
    cd C:\Stable-Diffusion\stable-diffusion-webui-directml

  3. Create the Virtual Environment: Run python -m venv venv

  4. Activate the Environment: Run venv\Scripts\activate. Your command prompt line will now start with (venv).

  5. Install the Correct PyTorch: This is the magic command. Run:
    pip install torch-directml torchvision
    This manually installs the version of PyTorch built for AMD cards using DirectML.

Error #3: RuntimeError: Input type (float) and bias type (struct c10::Half) should be the same

You launch again. The Web UI loads! But when you try to generate your first image, it crashes. This error means your RX 580's drivers are struggling with the default half-precision (FP16) math.

The Fix:

  1. Edit webui-user.bat one more time.

  2. We need to force the software to use full precision (FP32). Add the --no-half flag to your arguments. The line should now be:
    set COMMANDLINE_ARGS=--skip-torch-cuda-test --no-half

Part 4: The Final Optimization - From Working to Working Well

At this point, you can likely generate an image. But you might notice your CPU is working hard and your GPU is idle. The software has silently failed to initialize the GPU and has fallen back to the slow CPU mode.

The Problem: CPU Usage High, GPU Usage Low

This is the final hurdle. We need to explicitly tell the software how to use your GPU.

The Fix:

  1. Edit webui-user.bat for the last time.

  2. Add the --use-directml flag. This command directly orders the program to engage the DirectML backend for your AMD GPU.

Part 5: Your Golden Ticket - The Final webui-user.bat

After all this troubleshooting, your webui-user.bat file should contain this complete, optimized line. This combination ensures stability, forces GPU usage, and prevents all the common errors.

Batch
@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--skip-torch-cuda-test --opt-sub-quad-attention --lowvram --disable-nan-check --no-half --use-directml

call webui.bat

(Note: We also added 

Conclusion: You've Done It!

If you've followed this guide, you haven't just installed Stable Diffusion; you've battled through every major roadblock specific to older AMD hardware and won. The performance jump after the final --use-directml fix is massive—often more than doubling the speed.

You can now expect to generate a standard 512x512 image in about 1 to 1.5 minutes, with your GPU running at full tilt. While SDXL models will be a challenge, the vast universe of incredible Stable Diffusion 1.5 models is now at your fingertips.

No comments: