Skip to content

Import error in pytest with onnxruntime-directml 1.22.0 #24907

Open
@fairread

Description

@fairread

Describe the issue

Having DLL load error on Windows 11 with onnxruntime-directml 1.22.0 for my pytest test. Version 1.20.1, 1.20.0 tested working. Seems like version 1.22.0 no longer searches PATH for DLLs automatically?

MSVC redist version: 14.44.35208 (latest)
Pytest version tested: 8.2.2-8.3.3

Same issue identified for onnxruntime.

To reproduce

  1. Install onnx runtime with pip install onnxruntime-directml==1.22.0.
  2. Create test_1.py and test_2.py with the code below:
# test_1.py
def test_onnxruntime_directml_import():
    import onnxruntime
# test_2.py
import onnxruntime

def test_import_onnx():
    pass
  1. Run pytest test_1.py. This failed on my machine with the following error:
ImportError: DLL load failed while importing onnxruntime_pybind11_state: 
    A dynamic link library (DLL) initialization routine failed.
  1. Run pytest test_2.py. This also failed with the same error above.
  2. For comparison, run python and in python run >> import onnxruntime. This works fine on mine.

Urgency

No response

Platform

Windows

OS Version

Windows 11 Enterprise version 24H2

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.22.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

DirectML

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ep:DMLissues related to the DirectML execution providerstaleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions