microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.78k stars 2.94k forks source link

Cannot use Microsoft.ML.OnnxRuntime and WinUI 3 desktop: The target process exited without raising a CoreCLR started event #7237

Open jdluzen opened 3 years ago

jdluzen commented 3 years ago

Describe the bug I am attempting to build a machine learning application with the recently released WinUI 3 desktop. Adding the package Microsoft.ML.OnnxRuntime to an out of the box WinUI 3 app results in it being unable to run or debug with the following: The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.

Urgency While I do not technically have a deadline, it is a complete blocker, and I cannot continue. After searching and debugging for many hours over at least two days, I have found no workarounds so far.

System information

To Reproduce

Expected behavior The default WinUI 3 window to appear

Screenshots N/A

Additional context Some searches have suggested that upgrading the dependencies would resolve it, but the same behavior occurs. Relevant csproj:

    <TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>

It works, at least it runs and debugger attaches, with a .net5 console app.

fdwr commented 3 years ago

Joe, is this specific to Microsoft.ML.OnnxRuntime.DirectML, yet works fine with Microsoft.ML.OnnxRuntime? (https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime) I'm perplexed because ORT calls DirectML.dll, but DirectML has no C# or .NET dependencies itself. It's actually ORT which projects the C# API to the caller, above DML. @smk2007 informs me that Microsoft.ML.OnnxRuntime.DirectML depends on Microsoft.ML.OnnxRuntime.Managed, which pulls in .NETStandard v1.1.

jdluzen commented 3 years ago

You're correct, it does occur with Microsoft.ML.OnnxRuntime too, but not Microsoft.ML.OnnxRuntime.Managed. I'll edit the original post.

fdwr commented 3 years ago

@yuslepukhin : Turns out this wasn't DML specific and occurs with the CPU package too. Can someone more familiar with ORT's C# wrapper look?

jdluzen commented 3 years ago

I've found a workaround: do not reference Microsoft.ML.OnnxRuntime, but include onnxruntime.dll from the Nuget cache in the project, and copy to output.

fdwr commented 3 years ago

@jdluzen: I'm really not sure who to assign this issue to on ORT, but I see @jywu-msft reviewing the C# code in https://github.com/microsoft/onnxruntime/pull/7540. So I'll try him, and he might know who to reassign it to look into it further.