Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD Forge: cannot import name 'get_available_vram' from 'modules.sd_hijack_optimizations' #157

Open
JohnRDOrazio opened this issue Feb 9, 2025 · 0 comments

Comments

@JohnRDOrazio
Copy link

When attempting to install the plugin in SD Forge, I was first getting this error:

*** Error loading script: stablesr.py
    Traceback (most recent call last):
      File "/path-to/stable-diffusion-webui-forge/modules/scripts.py", line 525, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/path-to/stable-diffusion-webui-forge/modules/script_loading.py", line 13, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/path-to/stable-diffusion-webui-forge/extensions/sd-webui-stablesr/scripts/stablesr.py", line 52, in <module>
        from ldm.modules.diffusionmodules.openaimodel import UNetModel
    ModuleNotFoundError: No module named 'ldm'

---

Which I was able to fix by manually installing latent-diffusion from within the python virtual environment:

pip install git+https://github.com/CompVis/stable-diffusion.git

A bit surprisingly, the repo with the ldm package is actually https://github.com/CompVis/stable-diffusion.git and not https://github.com/CompVis/latent-diffusion.git .

However I then started getting these errors:

*** Error loading script: stablesr.py
    Traceback (most recent call last):
      File "/path-to/stable-diffusion-webui-forge/modules/scripts.py", line 525, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/path-tostable-diffusion-webui-forge/modules/script_loading.py", line 13, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/path-to/stable-diffusion-webui-forge/extensions/sd-webui-stablesr/scripts/stablesr.py", line 55, in <module>
        from srmodule.struct_cond import EncoderUNetModelWT, build_unetwt
      File "/path-to/stable-diffusion-webui-forge/extensions/sd-webui-stablesr/srmodule/struct_cond.py", line 20, in <module>
        from srmodule.attn import get_attn_func
      File "/path-to/stable-diffusion-webui-forge/extensions/sd-webui-stablesr/srmodule/attn.py", line 8, in <module>
        from modules.sd_hijack_optimizations import get_available_vram, get_xformers_flash_attention_op, sub_quad_attention
    ImportError: cannot import name 'get_available_vram' from 'modules.sd_hijack_optimizations' (/path-to/stable-diffusion-webui-forge/modules/sd_hijack_optimizations.py)

Any ideas on how to fix this last error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant