onnxruntime
onnxruntime copied to clipboard
onnxruntime-directml import interference with sklearn
Describe the issue
There is a weird bug when working with sklearn and onnxruntime-directml. When running natively with python, if the sklearn is imported before onnxruntime, the onnxruntime will throw DLL load failed exception:
...\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.
This behavior can be fixed by import onnxruntime first. However, in pyinstaller packed executable, rearrange the import order does not fix the issues.
To reproduce
A simple script to reproduce, the code below will throw exception:
import numpy
import sklearn
import onnxruntime
print(onnxruntime.__version__)
The code below works:
import numpy
import onnxruntime
import sklearn
print(onnxruntime.__version__)
Urgency
No response
Platform
Windows
OS Version
11 (Build number) 22631.3880)
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.18.1
ONNX Runtime API
Python
Architecture
X64
Execution Provider
DirectML
Execution Provider Library Version
No response
ImportError: DLL load failed while importing onnxruntime_pybind11_state: 动态链接库(DLL)初始化例程失败。
It seems that building pyinstaller exe on a minimal script with onnxruntime-directml and a few libraries will pass. Compile the onnxruntime part into a single file and make the main process to use it.
Applying stale label due to no activity in 30 days
Applying stale label due to no activity in 30 days
Closing issue due to no activity in 30 days