mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-03-22 14:20:39 -07:00
Merge 3e5c3318f2 into 82a973c043
This commit is contained in:
commit
b7d20e0eb7
7 changed files with 119 additions and 11 deletions
|
|
@ -3,6 +3,14 @@ A web interface for Stable Diffusion, implemented using Gradio library.
|
|||
|
||||

|
||||
|
||||
## 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
|
||||
|
|
|
|||
79
docs/rtx5090-compatibility.md
Normal file
79
docs/rtx5090-compatibility.md
Normal file
|
|
@ -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.
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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":
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue