[Bug]: ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed' (with dev aa4a451)
Checklist
- [X] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [ ] The issue has not been reported before recently
- [X] The issue has been reported before but has not been fixed yet
What happened?
Running the WebUI yields the following error:
ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed'
Steps to reproduce the problem
- Try to run the webui on a fresh installation with the version locked requirements.txt
What should have happened?
The WebUI should not crash.
What browsers do you use to access the UI ?
No response
Sysinfo
Unable to provide, crashes before even being able to dump
Console logs
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
Warning: k_diffusion not found at path /nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/repositories/k-diffusion/k_diffusion/sampling.py
Traceback (most recent call last):
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/webui.py", line 13, in <module>
initialize.imports()
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/modules/initialize.py", line 35, in imports
from modules import shared_init
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/modules/shared_init.py", line 5, in <module>
from modules import shared
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/modules/shared.py", line 6, in <module>
from modules import shared_cmd_options, shared_gradio_themes, options, shared_items, sd_models_types
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/modules/sd_models_types.py", line 1, in <module>
from ldm.models.diffusion.ddpm import LatentDiffusion
File "/nix/store/xikw87zzszkl8amyr9r1igggj28qw8mw-stable-diffusion-webui-git/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 20, in <module>
from pytorch_lightning.utilities.distributed import rank_zero_only
ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed'
Additional information
This is caused by the import call here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/aa4a45187eda51fe564139e0087d119b981ca66d/modules/initialize.py#L35
The WebUI attempts to apply a fix here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/aa4a45187eda51fe564139e0087d119b981ca66d/modules/initialize.py#L54
However, since the imports() function is called before initialize() is called, this doesn't fix the issue.
Locations: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/aa4a45187eda51fe564139e0087d119b981ca66d/webui.py#L13 Implicitly called (due to importing) before this: https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/aa4a45187eda51fe564139e0087d119b981ca66d/webui.py#L52
+1. #15310 was intended to fix this but seems to have failed to do so. Verified with a30b19dd (head of dev atm)
I just tried to install this in a docker container following the instructions to the letter. In the release tag, master and dev branches i all get this error (at revision 1da490792794e135ba8f0d7b8c78ddab564d7530, the current dev head):
REQS_FILE='requirements.txt' python launch.py --precision full --no-half
Python 3.9.19 (main, Mar 21 2024, 17:11:28)
[GCC 11.2.0]
Version: v1.9.4-244-g1da49079
Commit hash: 1da490792794e135ba8f0d7b8c78ddab564d7530
Launching Web UI with arguments: --precision full --no-half
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
Traceback (most recent call last):
File "/dockerx/stable-diffusion-webui/launch.py", line 48, in <module>
main()
File "/dockerx/stable-diffusion-webui/launch.py", line 44, in main
start()
File "/dockerx/stable-diffusion-webui/modules/launch_utils.py", line 465, in start
import webui
File "/dockerx/stable-diffusion-webui/webui.py", line 13, in <module>
initialize.imports()
File "/dockerx/stable-diffusion-webui/modules/initialize.py", line 35, in imports
from modules import shared_init
File "/dockerx/stable-diffusion-webui/modules/shared_init.py", line 5, in <module>
from modules import shared
File "/dockerx/stable-diffusion-webui/modules/shared.py", line 6, in <module>
from modules import shared_cmd_options, shared_gradio_themes, options, shared_items, sd_models_types
File "/dockerx/stable-diffusion-webui/modules/sd_models_types.py", line 1, in <module>
from ldm.models.diffusion.ddpm import LatentDiffusion
File "/dockerx/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 20, in <module>
from pytorch_lightning.utilities.distributed import rank_zero_only
ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed'
This https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11458#issuecomment-1609900319 did fix it!
The bug is still there:
root@debian:/dockerx/stable-diffusion-webui# REQS_FILE='requirements.txt' python launch.py --precision full --no-half
Python 3.10.15 (main, Oct 3 2024, 07:27:34) [GCC 11.2.0]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Launching Web UI with arguments: --precision full --no-half
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
Traceback (most recent call last):
File "/dockerx/stable-diffusion-webui/launch.py", line 48, in <module>
main()
File "/dockerx/stable-diffusion-webui/launch.py", line 44, in main
start()
File "/dockerx/stable-diffusion-webui/modules/launch_utils.py", line 465, in start
import webui
File "/dockerx/stable-diffusion-webui/webui.py", line 13, in <module>
initialize.imports()
File "/dockerx/stable-diffusion-webui/modules/initialize.py", line 35, in imports
from modules import shared_init
File "/dockerx/stable-diffusion-webui/modules/shared_init.py", line 5, in <module>
from modules import shared
File "/dockerx/stable-diffusion-webui/modules/shared.py", line 6, in <module>
from modules import shared_cmd_options, shared_gradio_themes, options, shared_items, sd_models_types
File "/dockerx/stable-diffusion-webui/modules/sd_models_types.py", line 1, in <module>
from ldm.models.diffusion.ddpm import LatentDiffusion
File "/dockerx/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 20, in <module>
from pytorch_lightning.utilities.distributed import rank_zero_only
ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed'
root@debian:/dockerx/stable-diffusion-webui#
I modify the code
from pytorch_lightning.utilities.distributed import rank_zero_only
to
from pytorch_lightning.utilities.rank_zero import rank_zero_only
fix the problem