Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: ImportError: DLL load failed while importing cv2: The specified module could not be found. #5204

Closed
1 task done
pidtuner opened this issue Nov 30, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@pidtuner
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

OS

Windows

GPU

cuda

VRAM

4GB

What version did you experience this issue on?

3.4.0post2

What happened?

Try to run and get greeted by:

ImportError: DLL load failed while importing cv2: The specified module could not be found.

I have updated Nvidia drivers, installed CUDA SDK, and no luck. Also tried a few commands from the internet, yet cannot seem to move on

This is the output, thanks in advance for any help:

Loading...
WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.0.0+cu118)
    Python  3.10.11 (you have 3.10.12)
  Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
  Memory-efficient attention, SwiGLU, sparse and more won't be available.
  Set XFORMERS_MORE_DETAILS=1 for more details
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
[2023-11-30 13:18:30,577]::[InvokeAI]::INFO --> Loaded 0 modules from D:\DownloadsDevelopment\invokeai3_standalone\invokeai\nodes
Traceback (most recent call last):
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\Scripts\invokeai-web.exe\__main__.py", line 4, in <module>
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\api_app.py", line 40, in <module>
    from .api.dependencies import ApiDependencies
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\api\dependencies.py", line 10, in <module>
    from ..services.board_images.board_images_default import BoardImagesService
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\services\board_images\board_images_default.py", line 3, in <module>
    from invokeai.app.services.invoker import Invoker
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\services\invoker.py", line 7, in <module>
    from .shared.graph import Graph, GraphExecutionState
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\services\shared\graph.py", line 12, in <module>
    from invokeai.app.invocations import *  # noqa: F401 F403
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\invokeai\app\invocations\controlnet_image_processors.py", line 7, in <module>
    import cv2
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\cv2\__init__.py", line 181, in <module>
    bootstrap()
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\site-packages\cv2\__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "D:\DownloadsDevelopment\invokeai3_standalone\env\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module could not be found.
Press any key to continue . . .

Screenshots

image

Additional context

No response

Contact Details

No response

@pidtuner pidtuner added the bug Something isn't working label Nov 30, 2023
@pidtuner
Copy link
Author

If is of any help:

>nvidia-smi
Thu Nov 30 13:40:14 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 546.17                 Driver Version: 546.17       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                     TCC/WDDM  | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce GTX 960M      WDDM  | 00000000:01:00.0 Off |                  N/A |
| N/A    0C    P8              N/A / 200W |      0MiB /  4096MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

@hipsterusername
Copy link
Member

Would consider a direct installation rather than the standalone, to see if that alleviates the issue.

@pidtuner
Copy link
Author

Would consider a direct installation

I just tried that, after full installation from scratch (marked as successful), I get the same exact error:

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'
[2023-11-30 15:34:01,414]::[InvokeAI]::INFO --> Loaded 0 modules from D:\DownloadsDevelopment\invikeai3\nodes
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\DownloadsDevelopment\invikeai3\.venv\Scripts\invokeai-web.exe\__main__.py", line 4, in <module>
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\api_app.py", line 40, in <module>
    from .api.dependencies import ApiDependencies
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\api\dependencies.py", line 10, in <module>
    from ..services.board_images.board_images_default import BoardImagesService
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\services\board_images\board_images_default.py", line 3, in <module>
    from invokeai.app.services.invoker import Invoker
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\services\invoker.py", line 7, in <module>    from .shared.graph import Graph, GraphExecutionState
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\services\shared\graph.py", line 12, in <module>
    from invokeai.app.invocations import *  # noqa: F401 F403
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\invokeai\app\invocations\controlnet_image_processors.py", line 7, in <module>
    import cv2
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\cv2\__init__.py", line 181, in <module>
    bootstrap()
  File "D:\DownloadsDevelopment\invikeai3\.venv\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing cv2: The specified module could not be found.

@pidtuner
Copy link
Author

Finally, the issue is that OpenCV has a dependency on the Windows Media Feature Pack that does not come pre-installed in all versions of Windows. I had to install it, and very importantly; reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants