# Stable Diffusion WebUI Forge

**AI Image Generation on shinku-ryuu**

## Service Overview

| Property | Value |
|----------|-------|
| **Host** | shinku-ryuu (100.98.93.15 via Tailscale) |
| **GPU** | NVIDIA RTX 4080 (16GB VRAM) |
| **CPU** | Intel i7-14700K |
| **RAM** | 96GB |
| **URL** | http://localhost:7860 (local) or http://100.98.93.15:7860 (Tailscale) |
| **Install path** | `C:\stable-diffusion-webui-forge` |
| **Launcher** | `C:\stable-diffusion-webui-forge\run-forge.bat` |
| **Python** | 3.10 via miniconda (conda env `forge`) |
| **Model** | SDXL Base 1.0 (6.9GB) |

## Starting Forge

Run on shinku-ryuu:
```
C:\stable-diffusion-webui-forge\run-forge.bat
```

The launcher activates the conda `forge` env, sets `--listen` (network access) and `--xformers` (VRAM optimization), then starts the WebUI.

## Recommended Settings

| Setting | Value |
|---------|-------|
| **Sampler** | DPM++ 2M SDE Karras |
| **Steps** | 30 |
| **CFG Scale** | 7 |
| **Resolution** | 1024x1024 (SDXL native) |
| **Clip Skip** | 2 |

### Hires Fix (for upscaling beyond 1024x1024)

| Setting | Value |
|---------|-------|
| **Upscaler** | 4x-UltraSharp or Latent |
| **Hires steps** | 15 |
| **Denoising strength** | 0.4 |
| **Upscale by** | 1.5 (gives 1536x1536) |

### Prompt Template

```
masterpiece, best quality, highly detailed, 8k, [style keywords], [subject], [scene/setting], [lighting], cinematic
```

### Negative Prompt

```
worst quality, low quality, blurry, deformed, ugly, distorted, text, watermark
```

## Models

Models go in `C:\stable-diffusion-webui-forge\models\Stable-diffusion\`.

| Model | Size | Resolution | Notes |
|-------|------|-----------|-------|
| `sdxl_base.safetensors` | 6.9GB | 1024x1024 | Default. Do NOT use 512x512 — produces noise. |

Additional models can be downloaded from https://civitai.com or https://huggingface.co.

## Setup Notes

- **Windows Defender exclusion**: `C:\stable-diffusion-webui-forge` is excluded from Defender scanning. Defender locks model files during scans, preventing Forge from loading them.
- **Conda env**: `forge` env with Python 3.10. Forge's venv uses this as the base interpreter.
- **setuptools**: Pinned to <71 in the venv to preserve `pkg_resources` (removed in setuptools 79+).
- **numpy**: Pinned to <2 for compatibility with scikit-image and other deps.
- **xformers**: Enabled via `--listen` flag. Triton is not available on Windows (harmless warning).

## Troubleshooting

| Issue | Fix |
|-------|-----|
| Garbled/noisy output | Use 1024x1024 resolution (not 512x512). SDXL needs native res. |
| `No module named 'pkg_resources'` | `pip install "setuptools<71"` in the venv |
| `numpy.dtype size changed` | `pip install "numpy<2"` in the venv |
| `PermissionError` on model file | Add Forge folder to Windows Defender exclusions |
| No model found | Download a `.safetensors` model to `models\Stable-diffusion\` |
| Slow generation | Add `--cuda-malloc` to COMMANDLINE_ARGS in `run-forge.bat` |
