Sanster/IOPaint

[BUG]The specified module could not be found. (fbgemm.dll)

DeerFee opened this issue · 2 comments

Title: OSError when importing torch: fbgemm.dll not found

When trying to run iopaint, I'm encountering an OSError related to the torch library. The error occurs when importing torch, specifically when trying to load the fbgemm.dll file.

Environment:

  • OS: Windows 10 (10.0.19045-SP0)
  • Python: 3.12.3
  • torch: 2.4.0
  • torchvision: 0.19.0
  • Pillow: 9.5.0
  • diffusers: 0.27.2
  • transformers: 4.43.3
  • opencv-python: 4.10.0.84
  • accelerate: 0.33.0
  • iopaint: 1.3.3
  • rembg: N/A
  • realesrgan: N/A
  • gfpgan: N/A

Error message:
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

Full traceback:
2024-08-02 16:59:00.867 | INFO | iopaint.runtime:setup_model_dir:82 - Model directory: C:\Users\user.cache

  • Platform: Windows-10-10.0.19045-SP0
  • Python version: 3.12.3
  • torch: 2.4.0
  • torchvision: 0.19.0
  • Pillow: 9.5.0
  • diffusers: 0.27.2
  • transformers: 4.43.3
  • opencv-python: 4.10.0.84
  • accelerate: 0.33.0
  • iopaint: 1.3.3
  • rembg: N/A
  • realesrgan: N/A
  • gfpgan: N/A

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\typer_config\decorators. │
│ py:92 in wrapped │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\iopaint\cli.py:164 in │
│ start │
│ │
│ 161 │ │ os.environ["TRANSFORMERS_OFFLINE"] = "1" │
│ 162 │ │ os.environ["HF_HUB_OFFLINE"] = "1" │
│ 163 │ │
│ ❱ 164 │ from iopaint.download import cli_download_model, scan_models │
│ 165 │ │
│ 166 │ scanned_models = scan_models() │
│ 167 │ if model not in [it.name for it in scanned_models]: │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\iopaint\download.py:19 │
│ in │
│ │
│ 16 │ DIFFUSERS_SDXL_INPAINT_CLASS_NAME, │
│ 17 │ ANYTEXT_NAME, │
│ 18 ) │
│ ❱ 19 from iopaint.model.original_sd_configs import get_config_files │
│ 20 │
│ 21 │
│ 22 def cli_download_model(model: str): │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\iopaint\model_init_.p │
│ y:1 in │
│ │
│ ❱ 1 from .anytext.anytext_model import AnyText │
│ 2 from .controlnet import ControlNet │
│ 3 from .fcf import FcF │
│ 4 from .instruct_pix2pix import InstructPix2Pix │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\iopaint\model\anytext\an │
│ ytext_model.py:1 in │
│ │
│ ❱ 1 import torch │
│ 2 from huggingface_hub import hf_hub_download │
│ 3 │
│ 4 from iopaint.const import ANYTEXT_NAME │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch_init_.py:148 in │
│ │
│ │
│ 145 │ │ │ if res is None: │
│ 146 │ │ │ │ err = ctypes.WinError(ctypes.get_last_error()) │
│ 147 │ │ │ │ err.strerror += f' Error loading "{dll}" or one of its dependencies.' │
│ ❱ 148 │ │ │ │ raise err │
│ 149 │ │
│ 150 │ kernel32.SetErrorMode(prev_error_mode) │
│ 151 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: [WinError 126] The specified module could not be found. Error loading
"C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\lib\fbgemm.dll" or one of its
dependencies.

Steps to reproduce:

  1. Install iopaint and its dependencies
  2. Run iopaint

Expected behavior:
iopaint should start without errors.

Actual behavior:
The application crashes with the OSError mentioned above.

Additional notes:

  • The error seems to be related to the torch library and its ability to load the fbgemm.dll file.
  • This might be a compatibility issue between the installed versions of Python, torch, and iopaint.

Any help or guidance on resolving this issue would be greatly appreciated.

Installing torch 2.3.0 fixed the issue for me.

I tried torch 2.3.1 and 2.1.2 and I get another error : "AttributeError: module 'torch.library' has no attribute 'register_fake'"

(Windows 10 with AMD GPU so using --device=GPU)