AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: RuntimeError: cannot import name '_compare_version' from 'torchmetrics.utilities.imports' #11648

Open roxas122 opened 1 year ago

roxas122 commented 1 year ago

Is there an existing issue for this?

What happened?

Use Google Colab and run into problems: cannot import name '_compare_version' from 'torchmetrics.utilities.imports'

Steps to reproduce the problem

  1. Use Google Colab
  2. Clone the repo using git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  3. run %pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117
  4. run !git checkout 11d432d
  5. Start the webui-user.bat

What should have happened?

The Web-UI should have launched without any errors.

Version or Commit where the problem happens

11d432d

What Python version are you running on ?

None

What platforms do you use to access the UI ?

Windows

What device are you running WebUI on?

No response

Cross attention optimization

Automatic

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--share --gradio-debug --disable-safe-unpickle --reinstall-xformers --enable-insecure-extension-access --opt-channelslast

List of extensions

No

Console logs

Traceback (most recent call last):
  File "/content/test1/launch.py", line 295, in <module>
    start()
  File "/content/test1/launch.py", line 286, in start
    import webui
  File "/content/test1/webui.py", line 15, in <module>
    from modules import shared, devices, sd_samplers, upscaler, extensions, localization, ui_tempdir
  File "/content/test1/modules/sd_samplers.py", line 12, in <module>
    from modules import prompt_parser, devices, processing, images, sd_vae_approx
  File "/content/test1/modules/processing.py", line 15, in <module>
    import modules.sd_hijack
  File "/content/test1/modules/sd_hijack.py", line 4, in <module>
    import modules.textual_inversion.textual_inversion
  File "/content/test1/modules/textual_inversion/textual_inversion.py", line 13, in <module>
    from modules import shared, devices, sd_hijack, processing, sd_models, images, sd_samplers
  File "/content/test1/modules/sd_models.py", line 18, in <module>
    from modules.sd_hijack_inpainting import do_inpainting_hijack, should_hijack_inpainting
  File "/content/test1/modules/sd_hijack_inpainting.py", line 7, in <module>
    import ldm.models.diffusion.ddpm
  File "/content/test1/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 12, in <module>
    import pytorch_lightning as pl
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/__init__.py", line 34, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/__init__.py", line 25, in <module>
    from pytorch_lightning.callbacks.progress import ProgressBarBase, RichProgressBar, TQDMProgressBar
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/progress/__init__.py", line 22, in <module>
    from pytorch_lightning.callbacks.progress.rich_progress import RichProgressBar  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/progress/rich_progress.py", line 20, in <module>
    from torchmetrics.utilities.imports import _compare_version
ImportError: cannot import name '_compare_version' from 'torchmetrics.utilities.imports' (/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/imports.py)

Additional information

I don't know programming so don't know how to try to fix. I would like to keep using 11d432d if I could.

UESTCSober commented 9 months ago

try downgrade torchmetrics to torchmetrics==0.11.4

It works.

SheldonWxy commented 9 months ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。

zc61536337 commented 8 months ago

try downgrade torchmetrics to torchmetrics==0.11.4 尝试将 Torchmetrics 降级为 TorchMetrics==0.11.4

可以,真的有效果,谢谢!

SheldonWxy commented 8 months ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。

dtasev commented 7 months ago

I just commented out the _compare_version call and import in webui\venv\Lib\site-packages\pytorch_lightning\callbacks\progress\rich_progress.py. Seems to be part of a progress bar so likely not super essential

Edit: this & other problems were caused primarily that I had simply not updated (i.e. ran update.bat or git pull) the local code I had and it was >3000 commits behind. After updating to the latest src on master all issues disappeared so it could be worth double checking for sanity

SheldonWxy commented 4 months ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。