Describe the bug
I'm trying to create a Ort::Session that uses the DML provider but I keep getting this error every time:
Exception thrown at 0x00007FF98C667E50 (directml.dll) in ONNXPlayground.exe: 0xC0000005: Access violation writing location 0x00007FF971E74950.
I build the onnxruntime from source with DML support using the provided guide.
Urgency
If there are particular important use cases blocked by this or strict project-related timelines, please share more information and dates. If there are no hard deadlines, please specify none.
System information
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x64To Reproduce
Ort::SessionOptions ort_session_options;
OrtSessionOptionsAppendExecutionProvider_DML(ort_session_options, id);
m_session = Ort::Session(m_env, L"densenet121.onnx", ort_session_options);
Expected behavior
I should be able to create a session that runs with the DML provider
Screenshots
N/A
Additional context
Add any other context about the problem here. If the issue is about a particular model, please share the model details as well to facilitate debugging.
cc @fdwr @adtsai
@stefanpantic : Which version of the densenet file are you using? (opset 3, 6, 7, 8, 9?) https://github.com/onnx/models/tree/master/vision/classification/densenet-121
I tried a quick local repro via WinMLRunner.exe (https://github.com/microsoft/Windows-Machine-Learning/releases) using "WinMLRunner.exe -gpu -model densenet121.onnx" on my AMD Radeon R7 200 Series, which passed. So I want to use the same exact model file. Thanks.
Hi, I'm using opset 8
@stefanpantic : Will look into it. 馃憤 I don't repro any issue on opset 8 :/.
Creating Session with GPU: AMD Radeon R7 200 Series
Binding (device = GPU, iteration = 1, inputBinding = CPU, inputDataType = Tensor, deviceCreationLocation = WinML)...[SUCCESS]
Evaluating (device = GPU, iteration = 1, inputBinding = CPU, inputDataType = Tensor, deviceCreationLocation = WinML)...[SUCCESS]
Maybe this helps: I got the same error when not copying the DirectML.dll from the ONNX runtime build directory to the app's binary folder.
The version doesn't seem to be compatible with the version installed by the OS.
Copying the DirectML.dll from the ONNX runtime's build output solved the issue for me.
@nikola-j @dulex123
@stefanpantic : Does patlevin's advice solve the AV, copying ORT's version of DML.dll to your application folder? The DML version that comes with ORT is a preview and has more functionality (and some changed interfaces) than the OS version. Granted, I would not expect a read AV, but I also don't expect it to work.
@fdwr : I had to copy directml.dll into the folder. Also you must call DisableMemPattern and SetSessionExecutionMode functions:
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_DML(session_options, 0));
session_options.DisableMemPattern();
session_options.SetExecutionMode(ExecutionMode::ORT_SEQUENTIAL);
session_ = Ort::Session(env, L"model.onnx", session_options);
Most helpful comment
@fdwr : I had to copy directml.dll into the folder. Also you must call DisableMemPattern and SetSessionExecutionMode functions:
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_DML(session_options, 0));session_options.DisableMemPattern();session_options.SetExecutionMode(ExecutionMode::ORT_SEQUENTIAL);session_ = Ort::Session(env, L"model.onnx", session_options);