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

[Mobile] Unable to load models in Xamarin iOS due to #15545 changes #19295

Closed
gsgou opened this issue Jan 28, 2024 · 6 comments
Closed

[Mobile] Unable to load models in Xamarin iOS due to #15545 changes #19295

gsgou opened this issue Jan 28, 2024 · 6 comments
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template

Comments

@gsgou
Copy link

gsgou commented Jan 28, 2024

Describe the issue

Crush on Microsoft.ML.OnnxRuntime.InferenceSession..ctor in Xamarin.iOS release mode only and Microsoft.ML.OnnxRuntime higher then 1.14.1 using in iOS Microsoft.ML.OnnxRuntime.Extensions.Dummy:

Marshal.GetDelegateForFunctionPointer (System.IntPtr ptr, System.Type t)
System.TypeInitializationException: Attempting to JIT compile method '(wrapper managed-to-native) intptr Microsoft.ML.OnnxRuntime.NativeMethods/DGetMapKeyType:wrapper_aot_native (object,intptr,intptr&)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
(wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
Microsoft.ML.OnnxRuntime.SessionOptions
Microsoft.ML.OnnxRuntime.SessionOptions..ctor () <0x1074cb264 + 0x00107> in <02a3e6a54f1e4988ae968f128df4091d#9f2d94840382105a7f9403abba49d318>:0
Microsoft.ML.OnnxRuntime.InferenceSession
Microsoft.ML.OnnxRuntime.InferenceSession..ctor (System.String modelPath) <0x1074be8e4 + 0x00057> in <02a3e6a54f1e4988ae968f128df4091d#9f2d94840382105a7f9403abba49d318>:0

I am getting in an iPhone 6s, iPhone SE (3rd generation), iPhone 15
XCode 14.2, XCode 15,0
Xamarin.iOS 16.4.0.18, 16.4.0.23

according to @skottmckay relates to #15545 introduced changes
#16463 (comment)

To reproduce

clone this repo: https://github.com/SuperCD/onnx-xamarin-error
Build and run in release the application on an ios device

Urgency

No response

Platform

Xamarin

OS Version

17.2.1

ONNX Runtime Installation

Released Package

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

None

ONNX Runtime Version or Commit ID

1.15.0 or higher

ONNX Runtime API

C#

Architecture

ARM64

Execution Provider

Default CPU, CoreML

Execution Provider Library Version

No response

@gsgou gsgou added the platform:mobile issues related to ONNX Runtime mobile; typically submitted using template label Jan 28, 2024
@gsgou
Copy link
Author

gsgou commented Jan 28, 2024

@skottmckay any plans to fix this for Xamarin or workarounds in iOS to extend Xamarin support?

@skottmckay
Copy link
Contributor

@gsgou
Copy link
Author

gsgou commented Jan 29, 2024

Thanks for pointing out on nightly builds @skottmckay
Current builds merged since 14 Jan fail on native linking:
1.17.0-dev-20240119-0139-a63b71eadb
1.17.0-dev-20240114-0649-fcdc385b17

error MT5209: Error: warning: ignoring duplicate libraries: '-lc++', '-lsqlite3', '-lz' Native linking
error MT5209: Error: warning: search path '/Users/$user/.nuget/packages/microsoft.ml.onnxruntime/1.17.0-dev-20240119-0139-a63b71eadb/runtimes/ios/native/onnxruntime.xcframework/ios-arm64' not found Native linking
error MT5209: Error: framework 'onnxruntime' not found Native linking
MTOUCH: Error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -lc++ -lc++ -ObjC -lc++ -lsqlite3 -lz -ObjC -lz -lsqlite3

@skottmckay
Copy link
Contributor

That's definitely unexpected. Looks like the iOS builds are missing in the package. Will look into it and make sure they're in the official 1.17 release.

@gsgou
Copy link
Author

gsgou commented Jan 29, 2024

Thanks, i ll follow up the releases, test and report regarding this and relevant linking issue.

YUNQIUGUO added a commit that referenced this issue Jan 30, 2024
…9311)

### Description
<!-- Describe your changes. -->

Updates to only include ios archs framework in artifacts included in
Nuget Package.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Related issue:
#19295 (comment)

---------

Co-authored-by: rachguo <rachguo@rachguos-Mini.attlocal.net>
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
YUNQIUGUO added a commit that referenced this issue Jan 30, 2024
…9311)

### Description
<!-- Describe your changes. -->

Updates to only include ios archs framework in artifacts included in
Nuget Package.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Related issue:
#19295 (comment)

---------

Co-authored-by: rachguo <rachguo@rachguos-Mini.attlocal.net>
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
@gsgou
Copy link
Author

gsgou commented Feb 2, 2024

@skottmckay, @YUNQIUGUO tks a lot was fixed in 1.17.0

@gsgou gsgou closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants