From b2880fad16f465939cd5053638d46123ce82f9d3 Mon Sep 17 00:00:00 2001 From: PiercingXX <155384428+PiercingXX@users.noreply.github.com> Date: Tue, 10 Mar 2026 18:46:17 -0400 Subject: [PATCH 1/2] Add RTX 5090 compatibility guards and startup docs --- docs/rtx5090-compatibility.md | 79 +++++++++++++++++++++++++++++++++++ modules/launch_utils.py | 4 +- modules/processing.py | 19 +++++++-- modules/sd_hijack.py | 3 +- modules/sd_hijack_unet.py | 9 ++-- modules/sd_models.py | 8 +++- 6 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 docs/rtx5090-compatibility.md diff --git a/docs/rtx5090-compatibility.md b/docs/rtx5090-compatibility.md new file mode 100644 index 000000000..d9f98be74 --- /dev/null +++ b/docs/rtx5090-compatibility.md @@ -0,0 +1,79 @@ +# RTX 5090 Compatibility Patch Notes + +## Summary +This branch adds compatibility guards and dependency fixes so AUTOMATIC1111 WebUI can run with modern RTX 5090 + PyTorch nightly (`cu128`) while using CompVis Stable Diffusion repository layout. + +## Code Changes + +### 1) Guard missing `ATTENTION_MODES` +- File: `modules/sd_hijack.py` +- Change: wrap assignment to `BasicTransformerBlock.ATTENTION_MODES` with `hasattr(...)`. +- Reason: some `ldm` variants do not define this attribute. + +### 2) Guard missing `use_linear` on `SpatialTransformer` +- File: `modules/sd_hijack_unet.py` +- Change: replace direct `self.use_linear` access with: + - `use_linear = getattr(self, "use_linear", False)` +- Reason: CompVis transformer blocks may not expose `use_linear`. + +### 3) Make depth class import optional +- File: `modules/processing.py` +- Change: `LatentDepth2ImageDiffusion` import wrapped in `try/except ImportError`. +- Change: `isinstance(...)` check now guarded by `LatentDepth2ImageDiffusion is not None`. +- Reason: class may not exist in all `ldm` implementations. + +### 4) Make `AddMiDaS` import optional +- File: `modules/processing.py` +- Change: `AddMiDaS` import wrapped in `try/except` with a no-op fallback class. +- Reason: `ldm.data.util` is absent in some CompVis repo states. + +### 5) Make MiDaS module optional +- File: `modules/sd_models.py` +- Change: wrap `import ldm.modules.midas as midas` in `try/except`. +- Change: `enable_midas_autodownload()` returns early when `midas is None`. +- Reason: prevents startup crash when MiDaS module is unavailable. + +### 6) Update default Stable Diffusion upstream for working clone path +- File: `modules/launch_utils.py` +- Change: `STABLE_DIFFUSION_REPO` default set to `https://github.com/CompVis/stable-diffusion.git`. +- Change: default `STABLE_DIFFUSION_COMMIT_HASH` set to `21f890f9da3cfbeaba8e2ac3c425ee9e998d5229`. +- Reason: previous default URL may be unreachable in current environment. + +## Environment / Install Actions +- Installed GitHub CLI (`gh`) in user path: `~/.local/bin/gh` +- Forked upstream: `AUTOMATIC1111/stable-diffusion-webui` -> `PiercingXX/stable-diffusion-webui` +- Cloned into: `/media/Working-Storage/GitHub/stable-diffusion-webui` +- Created branch: `feat/rtx5090-compat` + +Python environment: +- Python: `3.10.14` +- Torch: `2.12.0.dev20260310+cu128` +- CUDA available: `True` +- GPU detected: `NVIDIA GeForce RTX 5090` + +Installed dependencies: +- `requirements_versions.txt` +- `clip` (OpenAI CLIP zip, `--no-build-isolation`) +- `taming-transformers-rom1504` +- Additional runtime deps used by startup path (`pytorch_lightning`, `kornia`, `diskcache`, etc.) + +## Validation Performed + +### Runtime checks +- `torch.cuda.is_available()` -> `True` +- `torch.cuda.get_device_name(0)` -> `NVIDIA GeForce RTX 5090` + +### WebUI smoke startup +Command used for startup validation: +- `webui.py --skip-python-version-check --listen --server-name 0.0.0.0 --port 7860 --skip-load-model-at-start --no-download-sd-model` + +Observed in logs: +- `Running on local URL: http://0.0.0.0:7860` +- `Startup time: 4.2s ...` + +HTTP response verified: +- `curl http://0.0.0.0:7860/` returned HTML. + +## Notes / Remaining Validation +- Full text-to-image generation requires a model checkpoint to be present or fully downloaded. +- This branch has been validated for startup/runtime compatibility and serving UI on RTX 5090 stack. diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 20c7dc127..7f6556ef7 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -346,13 +346,13 @@ def prepare_environment(): openclip_package = os.environ.get('OPENCLIP_PACKAGE', "https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip") assets_repo = os.environ.get('ASSETS_REPO', "https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git") - stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/Stability-AI/stablediffusion.git") + stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/CompVis/stable-diffusion.git") stable_diffusion_xl_repo = os.environ.get('STABLE_DIFFUSION_XL_REPO', "https://github.com/Stability-AI/generative-models.git") k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/crowsonkb/k-diffusion.git') blip_repo = os.environ.get('BLIP_REPO', 'https://github.com/salesforce/BLIP.git') assets_commit_hash = os.environ.get('ASSETS_COMMIT_HASH', "6f7db241d2f8ba7457bac5ca9753331f0c266917") - stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf") + stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "21f890f9da3cfbeaba8e2ac3c425ee9e998d5229") stable_diffusion_xl_commit_hash = os.environ.get('STABLE_DIFFUSION_XL_COMMIT_HASH', "45c443b316737a4ab6e40413d7794a7f5657c19f") k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "ab527a9a6d347f364e3d185ba6d714e22d80cb3c") blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9") diff --git a/modules/processing.py b/modules/processing.py index 7535b56e1..a5ccf3e17 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -28,8 +28,21 @@ import modules.images as images import modules.styles import modules.sd_models as sd_models import modules.sd_vae as sd_vae -from ldm.data.util import AddMiDaS -from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion +try: + from ldm.data.util import AddMiDaS +except ImportError: + class AddMiDaS: + """Fallback no-op depth transform when ldm.data.util is unavailable.""" + + def __init__(self, *args, **kwargs): + pass + + def __call__(self, sample): + return sample +try: + from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion +except ImportError: + LatentDepth2ImageDiffusion = None from einops import repeat, rearrange from blendmodes.blend import blendLayers, BlendType @@ -377,7 +390,7 @@ class StableDiffusionProcessing: # HACK: Using introspection as the Depth2Image model doesn't appear to uniquely # identify itself with a field common to all models. The conditioning_key is also hybrid. - if isinstance(self.sd_model, LatentDepth2ImageDiffusion): + if LatentDepth2ImageDiffusion is not None and isinstance(self.sd_model, LatentDepth2ImageDiffusion): return self.depth2img_image_conditioning(source_image) if self.sd_model.cond_stage_key == "edit": diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 0de830541..1061b7f61 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -27,7 +27,8 @@ diffusionmodules_model_AttnBlock_forward = ldm.modules.diffusionmodules.model.At # new memory efficient cross attention blocks do not support hypernets and we already # have memory efficient cross attention anyway, so this disables SD2.0's memory efficient cross attention ldm.modules.attention.MemoryEfficientCrossAttention = ldm.modules.attention.CrossAttention -ldm.modules.attention.BasicTransformerBlock.ATTENTION_MODES["softmax-xformers"] = ldm.modules.attention.CrossAttention +if hasattr(ldm.modules.attention.BasicTransformerBlock, "ATTENTION_MODES"): + ldm.modules.attention.BasicTransformerBlock.ATTENTION_MODES["softmax-xformers"] = ldm.modules.attention.CrossAttention # silence new console spam from SD2 ldm.modules.attention.print = shared.ldm_print diff --git a/modules/sd_hijack_unet.py b/modules/sd_hijack_unet.py index b4f03b138..8070d6adc 100644 --- a/modules/sd_hijack_unet.py +++ b/modules/sd_hijack_unet.py @@ -87,17 +87,18 @@ def spatial_transformer_forward(_, self, x: torch.Tensor, context=None): b, c, h, w = x.shape x_in = x x = self.norm(x) - if not self.use_linear: + use_linear = getattr(self, "use_linear", False) + if not use_linear: x = self.proj_in(x) x = x.permute(0, 2, 3, 1).reshape(b, h * w, c) - if self.use_linear: + if use_linear: x = self.proj_in(x) for i, block in enumerate(self.transformer_blocks): x = block(x, context=context[i]) - if self.use_linear: + if use_linear: x = self.proj_out(x) x = x.view(b, h, w, c).permute(0, 3, 1, 2) - if not self.use_linear: + if not use_linear: x = self.proj_out(x) return x + x_in diff --git a/modules/sd_models.py b/modules/sd_models.py index 55bd9ca5e..a865d6cbf 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -10,7 +10,10 @@ import re import safetensors.torch from omegaconf import OmegaConf, ListConfig from urllib import request -import ldm.modules.midas as midas +try: + import ldm.modules.midas as midas +except ImportError: + midas = None from modules import paths, shared, modelloader, devices, script_callbacks, sd_vae, sd_disable_initialization, errors, hashes, sd_models_config, sd_unet, sd_models_xl, cache, extra_networks, processing, lowvram, sd_hijack, patches from modules.timer import Timer @@ -549,6 +552,9 @@ def enable_midas_autodownload(): location automatically. """ + if midas is None: + return + midas_path = os.path.join(paths.models_path, 'midas') # stable-diffusion-stability-ai hard-codes the midas model path to From 3e5c3318f29f83831b7fd893c00b6e3e0f098305 Mon Sep 17 00:00:00 2001 From: PiercingXX <155384428+PiercingXX@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:05:00 -0400 Subject: [PATCH 2/2] Add RTX 5090 compatibility note to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index bc62945c0..ebc30dde5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ A web interface for Stable Diffusion, implemented using Gradio library. ![](screenshot.png) +## RTX 5090 Compatibility Fork + +This fork includes compatibility updates for running with RTX 5090 GPUs and recent PyTorch nightly builds. + +- Branch with changes: `feat/rtx5090-compat` +- Key compatibility notes: optional guards for evolving `ldm`/CompVis APIs and startup robustness improvements +- Full patch details: `docs/rtx5090-compatibility.md` + ## Features [Detailed feature showcase with images](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features): - Original txt2img and img2img modes