-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Same model succeeded in Python but failed in C# with DML EP #13429
Comments
Dmitri's initial investigation indicates a packaging problem rather than a C# binding or DirectML issue. Evidently when building the C# program via Visual Studio, the build step is not unpacking the DLL from the Nuget package (and since the program is not finding DirectML.dll in the application directory, it falls back to the older system version, which didn't support those parameters). Manually copying the DirectML.dll from inside the Nuget package alongside the application made it work again, confirming that was the issue. Stay tuned... |
Thanks for the explanations, but manually copying DirectML.dll does not seem to work on my machine. By the way, I've got no idea whether I copied the right DLLs to the application directory. Here is the program I built myself for testing this issue, which was targeted to .net framework 4.8: |
Stay tuned for specific recommendations. |
Long story short. There is a bug with Microsoft.AI.DirectML package. In the projects that are targeted to Install and restore 3 packages see the picture below. The workaround currently is to target a specific arch. And those DirectML appears automatically where they should be. Otherwise, you just extract those DLLs manually. I am using VS 2022. Go to your binary Your original program that you gave when reporting the issue runs as intended.
|
A correction is in order. |
The fact that DirectML.dll ships as a system component makes it too easy for applications to load the wrong library at runtime. Therefore, one must make sure that the correct library is used during development and runtime. |
Something really wired is that when I use |
Describe the issue
The same ONNX model can run in Python but cannot run in C# with DirectML execution provider, with the following error message:
The error messages above appears in every time when I ran this model in C# on DirectML. No errors are produced if I use default CPU or CUDA providers, or if I run this model in Python.
Expected behaviors
The model should run with no errors both in Python and C#.
Device
The model fails both on an Intel(R) UHD Graphics 630 and a GTX 1050Ti Max Q in C#, and runs just fine on both devices in Python.
Model
tiny_model.zip
To reproduce
The following Python program runs without errors:
But the following C# program produces the above error:
Urgency
None, but it's quite wired that ONNXRuntime behaves the different in the two languages.
Platform
Windows
OS Version
Windows 10 21H2 19044.2130
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.12.1
ONNX Runtime API
C#
Architecture
X64
Execution Provider
DirectML
Execution Provider Library Version
1.9.0
The text was updated successfully, but these errors were encountered: