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

ImportError: Unable to import dependency onnxruntime #24120

Open
deepakd1411 opened this issue Mar 20, 2025 · 6 comments
Open

ImportError: Unable to import dependency onnxruntime #24120

deepakd1411 opened this issue Mar 20, 2025 · 6 comments

Comments

@deepakd1411
Copy link

hello Guys,
anyone knows how to solve this issue for comfyui,

File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface_init_.py", line 8, in
import onnxruntime
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime_init_.py", line 61, in
raise import_capi_exception
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime_init_.py", line 24, in
from onnxruntime.capi._pybind_state import (
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime\capi_pybind_state.py", line 32, in
from .onnxruntime_pybind11_state import * # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\nodes.py", line 2147, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 999, in exec_module
File "", line 488, in call_with_frames_removed
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor_init
.py", line 23, in
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor\nodes.py", line 15, in
from insightface.app.common import Face
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface_init_.py", line 10, in
raise ImportError(
ImportError: Unable to import dependency onnxruntime.

Cannot import E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor module for custom nodes: Unable to import dependency onnxruntime.
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
Traceback (most recent call last):
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface_init_.py", line 8, in
import onnxruntime
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime_init_.py", line 61, in
raise import_capi_exception
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime_init_.py", line 24, in
from onnxruntime.capi._pybind_state import (
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\onnxruntime\capi_pybind_state.py", line 32, in
from .onnxruntime_pybind11_state import * # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: DLL load failed while importing onnxruntime_pybind11_state: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\nodes.py", line 2147, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 999, in exec_module
File "", line 488, in call_with_frames_removed
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_pulid_flux_ll_init
.py", line 1, in
from .pulidflux import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_pulid_flux_ll\pulidflux.py", line 6, in
from insightface.utils.download import download_file
File "E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface_init_.py", line 10, in
raise ImportError(
ImportError: Unable to import dependency onnxruntime.

Cannot import E:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_pulid_flux_ll module for custom nodes: Unable to import dependency onnxruntime.

@snnn
Copy link
Member

snnn commented Mar 21, 2025

Most likely it was because your VC Runtime version was too old. If you could put it into a debugger(for example, Visual Studio), the debugger can tell you where msvcp140.dll was loaded. Then right click the file and check its version number from the file properties.

@tianleiwu
Copy link
Contributor

Try install nightly build: https://onnxruntime.ai/docs/install/#install-onnx-runtime-gpu-cuda-12x
It will tell which DLL is missing in Windows. The feature is added recently: #24053

When PyTorch is installed, you can walkaround this issue by using onnxruntime.preload_dlls(), see:
https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#compatibility-with-pytorch

@tqjason
Copy link

tqjason commented Mar 27, 2025

I have tried to install nightly build. But got the same error.

>>> from onnxruntime.capi._pybind_state import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\dev\anaconda3\lib\site-packages\onnxruntime\capi\_pybind_state.py", line 32, in <module>
    from .onnxruntime_pybind11_state import *  # noqa
ImportError: DLL load failed while importing onnxruntime_pybind11_state: 动态链接库(DLL)初始化例程失败。

no more DLL missing information.

I guest #24053 feature is about provider dll loading, not about onnxruntime_pybind11_state.pyd itself.

Now, it's onnxruntime_pybind11_state.pyd loading error.

my python is
Python 3.10.11
windows 11 x64 VM in Parallels Desktop on MacOS
only cpu, no cuda

@tianleiwu
Copy link
Contributor

@tqjason
Copy link

tqjason commented Apr 1, 2025

I have reinstalled latest vc_redist before I installed nightly build onnx. No help.

@tqjason
Copy link

tqjason commented Apr 1, 2025

But, python lib file \Lib\site-packages\onnxruntime\capi\onnxruntime_pybind11_state.pyd

There is "api-ms-win-core-path-l1-1-0.dll" in import table of onnxruntime_pybind11_state.pyd
And it is not in my windows.

I don't know if that is the reason, and how to install "api-ms-win-core-path-l1-1-0.dll".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants