Stable Diffusion WebUI Docker with AMD ROCm Support

This Docker setup provides a containerized version of Stable Diffusion WebUI with full AMD ROCm GPU acceleration support.

Features

  • AMD ROCm 5.7 support for GPU acceleration
  • gfx1100 (ROCm 11.0.0) GPU target configuration
  • PyTorch 2.0 with ROCm compatibility
  • Docker Compose for easy deployment
  • Persistent storage for models, outputs, and configurations
  • Optimized Docker build with multi-stage construction

Compatibility Notes

This configuration uses older versions for compatibility with the upstream Stable Diffusion WebUI project:

  • ROCm 5.7
  • Ubuntu 22.04
  • PyTorch 2.0

GPU Compatibility: This setup may not work with GPUs newer than the Radeon RX 7900 XTX. For newer GPUs, users may wish to try updating to newer ROCm versions (7.11+) and Ubuntu versions (24.04+).

For newer hardware compatibility, consider:

  1. Updating ROCm to version 7.11 or later
  2. Using Ubuntu 24.04 LTS instead of 22.04
  3. Updating PyTorch to a newer version compatible with newer ROCm versions

This approach prioritizes stability and compatibility with the upstream project over newer hardware support.

Requirements

  • Docker Engine (20.10+ recommended)
  • Docker Compose (v2+ recommended)
  • AMD GPU with ROCm support (RDNA2/RDNA3 recommended)
  • Linux host system (for proper GPU passthrough)

Quick Start

1. Build the Docker image

docker-compose build

2. Start the container

docker-compose up -d

3. Access the Web UI

Open your browser to: http://localhost:7860

Configuration

Environment Variables

You can customize the setup using environment variables in the docker-compose.yml file:

  • HSA_OVERRIDE_GFX_VERSION: GPU target version (default: 11.0.0 for gfx1100)
  • HIP_VISIBLE_DEVICES: Which GPU devices to use (default: 0)
  • PYTORCH_ROCM_ARCH: PyTorch ROCm architecture (default: gfx1100)
  • CLI_ARGS: Additional command line arguments for launch.py

Volumes

The following directories are persisted as Docker volumes:

  • ./models - Model files
  • ./outputs - Generated images and outputs
  • ./extensions - WebUI extensions
  • ./config.json - Configuration file

GPU Configuration

The Docker setup automatically configures:

  • /dev/kfd - AMD KFD device for GPU acceleration
  • /dev/dri - Direct Rendering Infrastructure for display
  • Proper group permissions (video, render)

Customization

Change GPU Target

To use a different GPU target (e.g., gfx1030 for Navi 2x):

  1. Edit docker/docker-compose.yml
  2. Change HSA_OVERRIDE_GFX_VERSION to your target version
  3. Change PYTORCH_ROCM_ARCH accordingly

Add Custom Arguments

Modify the CLI_ARGS environment variable in docker-compose.yml to add custom launch arguments:

environment:
  - CLI_ARGS=--listen --port 7860 --xformers --opt-sdp-attention --your-custom-arg

Building for Different ROCm Versions

To use a different ROCm version:

  1. Edit docker/Dockerfile
  2. Change the ROCM_VERSION environment variable
  3. Update the PyTorch installation command to match the ROCm version
  4. Rebuild the container

Troubleshooting

GPU Not Detected

  • Ensure your host system has ROCm properly installed
  • Check that the video and render groups exist on your host
  • Verify that /dev/kfd and /dev/dri devices exist

Build Failures

  • Ensure you have enough disk space (ROCm installation requires ~5GB)
  • Check your internet connection for downloading ROCm packages
  • Try cleaning the Docker build cache: docker system prune -a

Performance Issues

  • Make sure your GPU is properly supported by ROCm 5.7
  • Check that the correct HSA_OVERRIDE_GFX_VERSION is set for your GPU
  • Monitor GPU usage with rocm-smi on the host system

Updating

To update to the latest version:

docker-compose down
git pull
docker-compose build --no-cache
docker-compose up -d

License

This Docker configuration is provided under the same license as the Stable Diffusion WebUI project (AGPL-3.0).

S
Description
A docker build of automatic1111's stablediffusion-webui with ROCm support.
Readme
32 KiB
Languages
Dockerfile 64%
Shell 36%