Skip to content
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

Onnxruntime errors on startup of Unity Project #12

Closed
311-code opened this issue Jan 14, 2024 · 8 comments
Closed

Onnxruntime errors on startup of Unity Project #12

311-code opened this issue Jan 14, 2024 · 8 comments

Comments

@311-code
Copy link

311-code commented Jan 14, 2024

I noticed the onnxruntime .dll files show 3 errors by default when you open this project in Unity, and are not set to "load on startup" so I selected all the onnxruntime dll files under \DEPTH\Assets\Plugins\OnnxRuntimeDlls\win-x64 and set load on startup.

They try to load now but there are 4 new errors I highlighted for all of them about "expected x64 architecture, but was Unknown architecture. You must recompile your plugin for x64 architecture." I am using 64 bit Unity version 2021.3.10f1 I have tried on two separate systems and same errors.

error

I tried to change the any platform and platform settings for the .dll but it makes no difference.

@parkchamchi
Copy link
Owner

That's weird,

  • Does the build version of the program can run OnnxRuntime?
  • Can you try other versions of OnnxRuntime dlls - as here?

@311-code
Copy link
Author

311-code commented Jan 15, 2024

Yes your build version works great, I just used beit model with onnx Cuda setting and it works. I can't build because of the errors, It doesn't seem to work with the other .dll files either.

I even tried replacing all the onnx .dll files for the Unity the project completely and used dependencies program to analyze, they are all 64-bit, but always the same error. It doesn't really make sense to me since it's 64-bit unity and correct version.

@parkchamchi
Copy link
Owner

parkchamchi commented Jan 17, 2024

This is really weird. To test furthermore I suggest you delete all other dll files other than Microsoft.ML.OnnxRuntime.dll, which is a wrapper of actual native library. Just to clear it out, since the other ones are not needed to build the program.

  • Can you check git --diff to see if there is any differences between the master?
  • Can you check the MD5 (or SHA-256) hash of the dll file?
  • Can you try switching Microsoft.ML.OnnxRuntime.dll with other ones in here, like the one in netstandard2.0? Wrong link, sorry

If none works just remove the dll files and comment out using Microsoft.ML.OnnxRuntime... and the code inside all subroutines in OnnxRuntimeDepthModelBehavior.cs to skip this issue.

@311-code
Copy link
Author

311-code commented Jan 17, 2024

Could this be why? I didn't notice this error before when git cloning (wasn't paying attention after I cloned repo)
error2

error

I'm not sure what this means or what to do. I also tried manually downloading the zip file and git clone https://github.com/parkchamchi/DepthViewer for repo but same problem.

error3

I have tried downloading the file separately like you said though but the only file present in the Microsoft.ML.OnnxRuntime.DirectML.1.16.3.nuget (renamed to .zip and extract) \build\netstandard2.0 is Microsoft.ML.OnnxRuntime.DirectML.props

I deleted all the other dll's but is still also getting microsoft ML missing errors due to it being probably not downloading correctly from your repo. Having a very hard time finding Microsoft.ML.OnnxRuntime.dll online (130kb). The link you posted doesn't work also. I will try your other workarounds, hoping this will not disable onnx gpu acceleration though by doing this?

@311-code
Copy link
Author

311-code commented Jan 17, 2024

Update: I could only compare the sha256 because that's all I can see on github, they are indeed different. also the release build also doesn't have the Microsoft.ML.OnnxRuntime.dll at all in plugins/onnxruntime folder.

compare1

compare2

I can't download that file directly from repo either it's just downloading a 12kb pointer file replacement of Microsoft.ML.OnnxRuntime.dll not the 130kb version, and I can't find it anywhere online or in the nugets, microsoft github, or source unity project. (it's only 131 bytes in the project)

Edit: I finally got it to start without errors by copying the .dll files directly from the release build to the project build plugins folder (which does not have Microsoft.ML.OnnxRuntime.dll. in there) I used the readme file in the plugins folder and finally found a useable Microsoft.ML.OnnxRuntime.dll file (i went through many many packages and it wasn't present in any of them only .props file) but it was 202kb and still does not match the sha256 and 130kb of the github description.

I think the problem before was the onnxruntime files were also truncated from lfs error and replacing them didn't work because it still needed this non-truncated Microsoft.ML.OnnxRuntime.dll file, so now that I have this version of the file no more ML errors or unknown architecture, but Getting some new build errors about duplicate "lib_burst_generated.dll" (it's only in one place when I checked in onnxruntime folder):
build

Edit: I disabled burst complication for now in the project settings and the project works now, not sure how to fix that.

@311-code
Copy link
Author

I think there may be a problem now with the 202kb Microsoft.ML.OnnxRuntime.dll file I used, can't load custom models now after I build, they show up in the list but it gives this error in console after clicking load:

modelload-issue

@parkchamchi
Copy link
Owner

Yup, my Git LFS bandwith was full (1.7GB out of 1GB), so you would get corrupted dll files -- which Unity could not parse.

I have tried downloading the file separately like you said though but the only file present in the Microsoft.ML.OnnxRuntime.DirectML.1.16.3.nuget (renamed to .zip and extract) \build\netstandard2.0 is Microsoft.ML.OnnxRuntime.DirectML.props

You are not meant to download .DirectML, what is needed is .Gpu and .Managed. .Gpu is actual native libraries and .Managed is the C# binding. More info here

I think there may be a problem now with the 202kb Microsoft.ML.OnnxRuntime.dll file I used, can't load custom models now after I build, they show up in the list but it gives this error in console after clicking load:

Are onnxruntime.dll, onnxruntime_providers_shared.dll, onnxruntime_providers_cuda.dll present in the Plugins/? The are not needed for the build but are the actual native libraries.

@311-code
Copy link
Author

311-code commented Jan 18, 2024

Yes all present. I was just able to resolve this 10 minutes ago using microsoft.ml.onnxruntime.managed.1.12.0.nuget it was the only file I could find that has the lib folder and a 130kb Microsoft.ML.OnnxRuntime.dll file.

It's working now! The ones I tried in the readme though in plugins folder did not have the Microsoft.ML.OnnxRuntime.dll file anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants