129 lines
3.3 KiB
Markdown
129 lines
3.3 KiB
Markdown
|
|
# 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
|
||
|
|
|
||
|
|
## 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
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker-compose build
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2. Start the container
|
||
|
|
|
||
|
|
```bash
|
||
|
|
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:
|
||
|
|
|
||
|
|
```yaml
|
||
|
|
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:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
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).
|