-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support for loading a specific DirectML.dll #18831
Comments
Yo Carson. I wonder, do you then include a prebuilt (presumably from nuget or pypi) of both DirectML.dll and OnnxRuntime.dll beside your plugin? Is your plugin also a DLL, or something different like a script loaded by the app? In cases where the system DirectML.dll is loaded first, is that due to the application executable (presumably out of your control) loading DirectML.dll for its own needs, or maybe a different plugin loading DirectML? There are a few possibilities (e.g. ORT explicitly loading DirectML.dll from the same path as itstelf, adding some session option key:value for the custom DML name...), and it is possible to two different versions of DirectML.dll into the same process, but I'd like to understand the scenario a bit more. +@smk2007 too for any thoughts. |
Hi Dwayne, appreciate you getting back to me on this (and my other issue).
Yes. We build our own copy with the
Yes. Our plugin DLL is loaded by the application executable dynamically (LoadLibrary(...)) at some point after it has already initialized DirectML.dll for its own needs. I suppose the same issue could present itself if another plugin was loaded prior to our plugin that also loaded DirectML, but in the case I'm dealing with now it seems to be the host application itself (not sure if that would make a difference or not). (We do load onnxruntime using LoadLibrary too, rather than compile-time linking, and use the GetApi function to load the API, because often these host applications will also already be running their own copy of onnxruntime as well. Something similar for DirectML would do the trick) Hope that helps to clear up our scenario for you :) |
👍 That clarifies the picture.
💡 Oh, well in that case, you have complete freedom to make whatever changes you need, right? Not that you want to diverge much from main (understandably), but can you unblock yourself by modifying this line... onnxruntime/onnxruntime/core/providers/dml/dml_provider_factory.cc Lines 469 to 474 in 2952cf8
...to load similarly to how WinML loads DirectML.dll (adjacent to itself via full path)? So onnxruntime.dll would DirectML.dll adjacent to itself: onnxruntime/winml/adapter/winml_adapter_dml.cpp Lines 25 to 47 in 2952cf8
(then we can think about what we ought to do in main 🤔...) |
Ah, awesome! That's super easy. I guess it makes sense that every subsequent call that is made to DirectML goes through the created device object. And, there is even an option already in the ort API to provide a pre-created device and command queue: https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/dml/dml_provider_factory.h#L111 So, I don't think any code change is necessary on the onnxruntime side at all! Thank you Dwayne, this makes life much easier :) |
Derp, yes, that's even better. 👍 Cheers. |
Thank you for the insights. Could you please confirm that this is your approach to load the desired DirectML.dll?
I am not sure if understood your approach. I would really appreciate getting a small insight into your current solution to this problem and how you handle it. Thank you very much. |
Looks reasonable at a glance. Did it work for you? |
Describe the feature request
I'm running into some problems with the windows-provided DirectML install (in C:/windows/system32/DirectML.dll) conflicting with the DirectML.dll version that onnxruntime needs. As a plugin developer, I find that sometimes DirectML.dll is loaded into the host process before my plugin library has a chance to load the correct version of DirectML (often from system32). Because windows ships an old, incompatible version of DirectML (so much worse than not shipping it at all, IMO, but anyway...), when this happens my plugin crashes when attempting to run the DirectML EP via onnxruntime.
One solution is to copy DirectML.dll alongside the host application executable, but we can't use that in production at it would require essentially modifying the host application installation.
So, is there any recommended approach to handling this now? It would be nice to be able to configure the onnxruntime build such that onnxruntime.dll depends on a renamed version of DirectML.dll, say prefixed_DirectML.dll
Thank you!
Describe scenario use case
Video editing plugin development
The text was updated successfully, but these errors were encountered: