# Onnx runtime and ML2

**URL:** <https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220>\
**Category:** General\
**Created:** [July 18, 2023, 1:29am UTC](https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220 "2023-07-18T01:29:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattycorbett](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mattycorbett](https://forum.magicleap.cloud/u/mattycorbett)\
**Post date:** [July 18, 2023, 1:29am UTC](https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220/1 "2023-07-18T01:29:42Z")

</div>

I'm trying to use MS's onnx runtime packages on a project for the ML2. I'm using ORT becuase barracuda doesn't work for my model type. The code works in Unity, but the session (create by InferenceSession(), throws a null exception when I try to use Run(). This only happens on device and not in the Unity editor. Any ideas?

Specifically at this line:  
results = session.Run(inputs).First().AsEnumerable();

I get this exception:  
Object Reference Not Set To An Instance Of An Object  
2023-07-17 21:37:15.651;10106;16270;16290;Info;Unity;at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00000] in \<00000000000000000000000000000000\>:0;

* * *

Had a thought. It may be the the onnx file isnt being loaded propely. What directory does the file need to be in to be loaded?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [July 18, 2023, 3:52pm UTC](https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220/2 "2023-07-18T15:52:28Z")

</div>

Unfortunately, we are not familiar with this solution and recommend asking on the MS's Onnx Runtime Package's github.

You can also test if the issue is specific to Magic Leap 2 or Android, by testing the application on the Android Studio Simulator. Simply create a Unity 2D application that targets x86\_64 and deploy it to the virtual device. Make sure the device is configured for ( Android 10, x86\_64 , No Google Play services). If your application runs as expected, you can then deploy the 2D app to your headset and see if the issue persists.

---

<div class="post-metadata">

**Author:** ![mattycorbett](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mattycorbett](https://forum.magicleap.cloud/u/mattycorbett)\
**Post date:** [July 18, 2023, 5:08pm UTC](https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220/3 "2023-07-18T17:08:39Z")

</div>

OK. Is there a recommended way to run an SVM model on the ML2?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [August 4, 2023, 2:14pm UTC](https://forum.magicleap.cloud/t/onnx-runtime-and-ml2/2220/4 "2023-08-04T14:14:57Z")

</div>

I'm not sure I understand, SVM model?
