invoke-ai / InvokeAI

InvokeAI is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, supports terminal use through a CLI, and serves as the foundation for multiple commercial products.
https://invoke-ai.github.io/InvokeAI/
Apache License 2.0
22.87k stars 2.37k forks source link

[bug]: ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 application #2632

Closed Coreusa closed 1 year ago

Coreusa commented 1 year ago

Is there an existing issue for this?

OS

Windows

GPU

cuda

VRAM

12GB

What happened?

After installation, run Web-UI. The command crashes with this log:

Python Version: 3.10.9 Pip Version: 23.0

Starting the InvokeAI browser-based UI..
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Program Files\Python3\lib\runpy.py:196 in _run_module_as_main                                 │
│                                                                                                  │
│   193 │   main_globals = sys.modules["__main__"].__dict__                                        │
│   194 │   if alter_argv:                                                                         │
│   195 │   │   sys.argv[0] = mod_spec.origin                                                      │
│ ❱ 196 │   return _run_code(code, main_globals, None,                                             │
│   197 │   │   │   │   │    "__main__", mod_spec)                                                 │
│   198                                                                                            │
│   199 def run_module(mod_name, init_globals=None,                                                │
│                                                                                                  │
│ C:\Program Files\Python3\lib\runpy.py:86 in _run_code                                            │
│                                                                                                  │
│    83 │   │   │   │   │      __loader__ = loader,                                                │
│    84 │   │   │   │   │      __package__ = pkg_name,                                             │
│    85 │   │   │   │   │      __spec__ = mod_spec)                                                │
│ ❱  86 │   exec(code, run_globals)                                                                │
│    87 │   return run_globals                                                                     │
│    88                                                                                            │
│    89 def _run_module_code(code, init_globals=None,                                              │
│                                                                                                  │
│ in <module>                                                                                      │
│                                                                                                  │
│   1 # -*- coding: utf-8 -*-                                                                      │
│   2 import re                                                                                    │
│   3 import sys                                                                                   │
│ ❱ 4 from ldm.invoke.CLI import main                                                              │
│   5 if __name__ == '__main__':                                                                   │
│   6 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│   7 │   sys.exit(main())                                                                         │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\ldm\invoke\CLI.py:15 in <module>                    │
│                                                                                                  │
│     12 │   os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"                                       │
│     13                                                                                           │
│     14 from ldm.invoke.globals import Globals                                                    │
│ ❱   15 from ldm.generate import Generate                                                         │
│     16 from ldm.invoke.prompt_parser import PromptParser                                         │
│     17 from ldm.invoke.readline import get_completer, Completer                                  │
│     18 from ldm.invoke.args import Args, metadata_dumps, metadata_from_png, dream_cmd_from_png   │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\ldm\generate.py:16 in <module>                      │
│                                                                                                  │
│     13 import traceback                                                                          │
│     14                                                                                           │
│     15 import cv2                                                                                │
│ ❱   16 import diffusers                                                                          │
│     17 import numpy as np                                                                        │
│     18 import skimage                                                                            │
│     19 import torch                                                                              │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\__init__.py:54 in <module>                │
│                                                                                                  │
│    51 │   │   get_polynomial_decay_schedule_with_warmup,                                         │
│    52 │   │   get_scheduler,                                                                     │
│    53 │   )                                                                                      │
│ ❱  54 │   from .pipelines import (                                                               │
│    55 │   │   AudioPipelineOutput,                                                               │
│    56 │   │   DanceDiffusionPipeline,                                                            │
│    57 │   │   DDIMPipeline,                                                                      │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\pipelines\__init__.py:18 in <module>      │
│                                                                                                  │
│    15 except OptionalDependencyNotAvailable:                                                     │
│    16 │   from ..utils.dummy_pt_objects import *  # noqa F403                                    │
│    17 else:                                                                                      │
│ ❱  18 │   from .dance_diffusion import DanceDiffusionPipeline                                    │
│    19 │   from .ddim import DDIMPipeline                                                         │
│    20 │   from .ddpm import DDPMPipeline                                                         │
│    21 │   from .dit import DiTPipeline                                                           │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\pipelines\dance_diffusion\__init__.py:2   │
│ in <module>                                                                                      │
│                                                                                                  │
│   1 # flake8: noqa                                                                               │
│ ❱ 2 from .pipeline_dance_diffusion import DanceDiffusionPipeline                                 │
│   3                                                                                              │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\pipelines\dance_diffusion\pipeline_dance_ │
│ diffusion.py:21 in <module>                                                                      │
│                                                                                                  │
│    18 import torch                                                                               │
│    19                                                                                            │
│    20 from ...utils import logging, randn_tensor                                                 │
│ ❱  21 from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline                        │
│    22                                                                                            │
│    23                                                                                            │
│    24 logger = logging.get_logger(__name__)  # pylint: disable=invalid-name                      │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\pipelines\pipeline_utils.py:36 in         │
│ <module>                                                                                         │
│                                                                                                  │
│    33                                                                                            │
│    34 from ..configuration_utils import ConfigMixin                                              │
│    35 from ..models.modeling_utils import _LOW_CPU_MEM_USAGE_DEFAULT                             │
│ ❱  36 from ..schedulers.scheduling_utils import SCHEDULER_CONFIG_NAME                            │
│    37 from ..utils import (                                                                      │
│    38 │   CONFIG_NAME,                                                                           │
│    39 │   DIFFUSERS_CACHE,                                                                       │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\schedulers\__init__.py:72 in <module>     │
│                                                                                                  │
│   69 except OptionalDependencyNotAvailable:                                                      │
│   70 │   from ..utils.dummy_torch_and_scipy_objects import *  # noqa F403                        │
│   71 else:                                                                                       │
│ ❱ 72 │   from .scheduling_lms_discrete import LMSDiscreteScheduler                               │
│   73                                                                                             │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\diffusers\schedulers\scheduling_lms_discrete.py:21  │
│ in <module>                                                                                      │
│                                                                                                  │
│    18 import numpy as np                                                                         │
│    19 import torch                                                                               │
│    20                                                                                            │
│ ❱  21 from scipy import integrate                                                                │
│    22                                                                                            │
│    23 from ..configuration_utils import ConfigMixin, register_to_config                          │
│    24 from ..utils import BaseOutput                                                             │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\scipy\__init__.py:217 in __getattr__                │
│                                                                                                  │
│   214 │                                                                                          │
│   215 │   def __getattr__(name):                                                                 │
│   216 │   │   if name in submodules:                                                             │
│ ❱ 217 │   │   │   return _importlib.import_module(f'scipy.{name}')                               │
│   218 │   │   else:                                                                              │
│   219 │   │   │   try:                                                                           │
│   220 │   │   │   │   return globals()[name]                                                     │
│                                                                                                  │
│ C:\Program Files\Python3\lib\importlib\__init__.py:126 in import_module                          │
│                                                                                                  │
│   123 │   │   │   if character != '.':                                                           │
│   124 │   │   │   │   break                                                                      │
│   125 │   │   │   level += 1                                                                     │
│ ❱ 126 │   return _bootstrap._gcd_import(name[level:], package, level)                            │
│   127                                                                                            │
│   128                                                                                            │
│   129 _RELOADING = {}                                                                            │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\scipy\integrate\__init__.py:91 in <module>          │
│                                                                                                  │
│    88 """  # noqa: E501                                                                          │
│    89                                                                                            │
│    90                                                                                            │
│ ❱  91 from ._quadrature import *                                                                 │
│    92 from ._odepack_py import *                                                                 │
│    93 from ._quadpack_py import *                                                                │
│    94 from ._ode import *                                                                        │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\scipy\integrate\_quadrature.py:14 in <module>       │
│                                                                                                  │
│     11 # trapezoid is a public function for scipy.integrate,                                     │
│     12 # even though it's actually a NumPy function.                                             │
│     13 from numpy import trapz as trapezoid                                                      │
│ ❱   14 from scipy.special import roots_legendre                                                  │
│     15 from scipy.special import gammaln, logsumexp                                              │
│     16 from scipy._lib._util import _rng_spawn                                                   │
│     17                                                                                           │
│                                                                                                  │
│ Q:\InvokeAI\.venv\lib\site-packages\scipy\special\__init__.py:663 in <module>           │
│                                                                                                  │
│   660                                                                                            │
│   661 from ._sf_error import SpecialFunctionWarning, SpecialFunctionError                        │
│   662                                                                                            │
│ ❱ 663 from . import _ufuncs                                                                      │
│   664 from ._ufuncs import *                                                                     │
│   665                                                                                            │
│   666 from . import _basic                                                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 application.

Screenshots

image

Additional context

Prior versions have worked without fault, but 2.3.0 complains about this.

Contact Details

No response

ebr commented 1 year ago

This is a bit odd:

Q:\InvokeAI\.venv\lib\site-packages\diffusers\pipelines\dance_diffusion\__init__.py:2   │
│ in <module>                                                                                      │
│                                                                                                  │
│   1 # flake8: noqa                                                                               │
│ ❱ 2 from .pipeline_dance_diffusion import DanceDiffusionPipeline                                 │
│   3

I'm not sure why it's trying to import DanceDiffusionPipeline. but maybe this is expected? @keturn does this look right to you?

keturn commented 1 year ago

diffusers is the type of Python package that tries to import everything in its top-level package.

But if we follow that traceback a bit further, we see that it's the import of scheduling_lms_discrete, aka the diffusers implementation of k_lms, and that's something we would have ended up importing in any case.

and ultimately it seems to be a scipy problem?

ebr commented 1 year ago

Indeed. It's just the path it took to get to the problem that looked odd to me. Thanks for clarifying the diffusers behaviour.

@Coreusa it's unclear what might be causing this. The DLL error makes me think that maybe your Windows system is missing some shared libraries? Perhaps you could try to (re)install the Visual C++ redistributable package (downloadable from Microsoft)? Not sure how helpful, but could be worth a try.

github-actions[bot] commented 1 year ago

There has been no activity in this issue for 14 days. If this issue is still being experienced, please reply with an updated confirmation that the issue is still being experienced with the latest release.

github-actions[bot] commented 1 year ago

Due to inactivity, this issue was automatically closed. If you are still experiencing the issue, please recreate the issue.