microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
13.92k stars 2.81k forks source link

Import error with onnxruntime-directml 1.18.1 #21270

Closed trevortai closed 1 month ago

trevortai commented 1 month ago

Describe the issue

I'm encountering a dll load error with onnxruntime-directml 1.18.1 on a Windows11 system:

File "C:\Users\Default\miniconda3\envs\onnx\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: A dynamic link library (DLL) initialization routine failed.

Issue is not seen with onnxruntime 1.18.1 or with onnxruntime-directml 1.18.0

To reproduce

Urgency

Regression in onnxruntime-directml, urgent for users on the latest

Platform

Windows

OS Version

11 Pro Build 22631

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

onnxruntime-directml 1.18.1

ONNX Runtime API

Python

Architecture

X64

Execution Provider

DirectML

Execution Provider Library Version

1.18.1

Royzxx commented 1 month ago

I'm having the exactly same issue. Tried many things but still haven't found a solution yet.

trevortai commented 1 month ago

I'm having the exactly same issue. Tried many things but still haven't found a solution yet.

Current workaround is to install onnxruntime-directml==1.18.0 instead

Jay19751103 commented 1 month ago

Previously I install the latest visual studio 17.10.x and build onnxruntime wheel. have this problem to use 17.10.x. Sometimes when I install msvc-runtime which is build by 17.10.x . it can resolve I have several conda environments. it sometimes have same issues. Finally I roll back my visual studio to 17.8 to prevent this issue.

deiteris commented 1 month ago

Latest release has bumped vcredist requirement to 14.38. Downloading and updating to 14.40 seems to help, but not sure if that's the only required fix. Github runners have 14.40 installed, and builds made with pyinstaller fail with the same problem.

zhangxiang1993 commented 1 month ago

You can try conda install conda-forge::vs2015_runtime

dongulee commented 1 month ago

I have encountered a similar issue. It seems onnxruntime package was built with conflicting dependency of visual c++.

I was using 14.29 vcredist, updating to 14.40 and then, resolved this error.

Refer to https://onnxruntime.ai/docs/install/#requirements

trevortai commented 1 month ago

You can try conda install conda-forge::vs2015_runtime

I have encountered a similar issue. It seems onnxruntime package was built with conflicting dependency of visual c++.

I was using 14.29 vcredist, updating to 14.40 and then, resolved this error.

Refer to https://onnxruntime.ai/docs/install/#requirements

Thanks, this solved the problem!

deiteris commented 1 month ago

You can try conda install conda-forge::vs2015_runtime

In case you use pip, msvc-runtime package also helps (and works with pyinstaller distributions). Thanks for the idea! :D

meokbodizi commented 2 weeks ago

wtf.. this issue suffered me for 2 weeks.