AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
143.48k stars 27.01k forks source link

[Bug]: Unable to find "sgm" #13191

Open zicheqingluo opened 1 year ago

zicheqingluo commented 1 year ago

Is there an existing issue for this?

What happened?

Warning: Stable Diffusion XL not found at path /data/rd/aigc/stable-diffusion/stable-diffusion-webui/repositories/generative-models/sgm Traceback (most recent call last): File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/webui.py", line 13, in initialize.imports() File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/modules/initialize.py", line 30, in imports import sgm.modules.encoders.modules # noqa: F401 ModuleNotFoundError: No module named 'sgm'

Steps to reproduce the problem

python webui.py

What should have happened?

What is “sgm”

Sysinfo

Warning: Stable Diffusion XL not found at path /data/rd/aigc/stable-diffusion/stable-diffusion-webui/repositories/generative-models/sgm Traceback (most recent call last): File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/webui.py", line 13, in initialize.imports() File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/modules/initialize.py", line 30, in imports import sgm.modules.encoders.modules # noqa: F401 ModuleNotFoundError: No module named 'sgm'

What browsers do you use to access the UI ?

No response

Console logs

Warning: Stable Diffusion XL not found at path /data/rd/aigc/stable-diffusion/stable-diffusion-webui/repositories/generative-models/sgm
Traceback (most recent call last):
  File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/webui.py", line 13, in <module>
    initialize.imports()
  File "/data/rd/aigc/stable-diffusion/stable-diffusion-webui/modules/initialize.py", line 30, in imports
    import sgm.modules.encoders.modules  # noqa: F401
ModuleNotFoundError: No module named 'sgm'

Additional information

No response

SuCicada commented 1 year ago

look at this. You need clone https://github.com/Stability-AI/generative-models.git at repositories/generative-models

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ef669de080814067961f28357256e8fe27544f4/modules/launch_utils.py#L320

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ef669de080814067961f28357256e8fe27544f4/modules/launch_utils.py#L381

jacobp-phaser commented 11 months ago

Also happening to me.

xuxuxbaobao2 commented 11 months ago

How to solve this problem?

ibaraki-douji commented 10 months ago

to fix it you need to clone it to the repositories folder

To fix sgm only the one below is needed. git clone https://github.com/Stability-AI/generative-models.git

In my case the k-diffusion was also missing so there you go git clone https://github.com/crowsonkb/k-diffusion.git

i-am-dom commented 9 months ago

Ok here's what worked for me. In my case, it was an indication of the bigger file structure conflict. If you can't solve it with cloning the rep, chances are you're experiencing something similar. After I cloned the rep and even manually imported sgm with importlib.util, I got module 'gradio' has no attribute 'themes'.

The solution: delete your 'SD' directory in the gdrive entirely and re-run the script from the start to reload it.

Mind you, this will likely work only if your script worked before but doesn't anymore. If you never successfully ran it to begin with or used other scripts which referenced SD directory, your problem is probably elsewhere.

PS. For reference, SGM is literally this: https://github.com/Stability-AI/generative-models/tree/main/sgm

RHxW commented 4 months ago
git clone https://github.com/Stability-AI/generative-models.git repositories/generative-models
cd repositories/generative-models
pip install -e .

it works for me