microsoft / onnxruntime

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

ONNX Runtime v1.16.2 crashes with Unity IDE #18441

Open Storm-Develop opened 9 months ago

Storm-Develop commented 9 months ago

Describe the issue

Starting from ONNX Runtime v1.15.0 Unity crashes upon trying to create inference session from the .onnx model.

Note: ONNX Runtime v1.14.1 works as expected.

It gives out of memory exception.

 =================================================================
    Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at System.Buffer:InternalMemcpy <0x000d5>
      at System.Buffer:Memcpy <0x0010a>
      at System.String:memcpy <0x00082>
      at Microsoft.ML.OnnxRuntime.NativeMethods:.cctor <0x001ba>
      at System.Object:runtime_invoke_void <0x00184>
      at <unknown> <0xffffffff>
      at System.Object:__icall_wrapper_mono_generic_class_init <0x000c2>
      at Microsoft.ML.OnnxRuntime.SessionOptions:.ctor <0x002c2>
      at Microsoft.ML.OnnxRuntime.InferenceSession:.ctor <0x0017a>

It seems like changes introduced at v1.15.0 break for Unity environment. It's targeting .NET Standard 2.1

To reproduce

Have UNITY IDE v 2022.3.3f1 or any other Unity 2022 version

Import Microsoft.ML.OnnxRuntime & Microsoft.ML.OnnxRuntime.Managed packages in the project

The import could be made by manually copying .NET Standard Microsoft.ML.OnnxRuntime DLL Or use Nuget Manager ( https://github.com/GlitchEnzo/NuGetForUnity) to install the Onnx packages

Try to create a session using onnx model. `using var session = new InferenceSession(path);

Run in the Unity editor in the playback mode or as Unity test.

Urgency

No response

Platform

Windows

OS Version

Windows 11 OS Build:22621.2428

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

v1.15.0

ONNX Runtime API

C#

Architecture

X64

Execution Provider

Other / Unknown

Execution Provider Library Version

No response

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

Storm-Develop commented 7 months ago

Well, the issue is still not resolved, any version after the v1.14.1 causes the crash in the Unity Editor.

tonglinyan commented 6 months ago

Hello, I'm using v1.17.1 and met the same problem. Have you find a solution to this?