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

Fixes a crash on macOS 15 when using CoreML. #22277

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Fixes a crash on macOS 15 when using CoreML. #22277

merged 1 commit into from
Oct 1, 2024

Conversation

marovira
Copy link
Contributor

Description

In macOS 15, apps running with CoreML will crash with an error message like this one:

Terminating app due to uncaught exception 'NSGenericException', reason: 'Failed to set compute_device_types_mask E5RT: Cannot provide zero compute device types. (1)'

This can be easily seen when building ONNXRuntime from source and running the unit tests. The fix was suggested in this bug report.
I've ported the change to ONNXRuntime and verified that:

  • The issue is resolved in macOS 15 (all unit tests pass).
  • The behaviour is unchanged in macOS 14.

Motivation and Context

This fixes #22275 allowing apps using ONNXRuntime with CoreML to work normally.

[detailed]
- The issue is seemingly caused by MLModelConfiguration not being
  correctly initialised, which in turn causes a crash due to
  compute_device_types_mask not being correctly set. This fixes the
  problem.
- Issue is not reproducible in macOS 14 or lower.
@snnn snnn added the ep:CoreML issues related to CoreML execution provider label Sep 30, 2024
@snnn
Copy link
Member

snnn commented Sep 30, 2024

/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline

@snnn
Copy link
Member

snnn commented Sep 30, 2024

/azp run Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows ARM64 QNN CI Pipeline

@snnn
Copy link
Member

snnn commented Sep 30, 2024

/azp run Windows CPU CI Pipeline, Windows GPU CUDA CI Pipeline, Windows GPU DML CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

Copy link

Azure Pipelines successfully started running 9 pipeline(s).

Copy link
Contributor

@edgchen1 edgchen1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix

@skottmckay skottmckay merged commit ffca096 into microsoft:main Oct 1, 2024
70 checks passed
ishwar-raut1 pushed a commit to ishwar-raut1/onnxruntime that referenced this pull request Nov 19, 2024
### Description
In macOS 15, apps running with CoreML will crash with an error message
like this one:
```
Terminating app due to uncaught exception 'NSGenericException', reason: 'Failed to set compute_device_types_mask E5RT: Cannot provide zero compute device types. (1)'
```

This can be easily seen when building ONNXRuntime from source and
running the unit tests. The fix was suggested in [this bug
report](https://forums.developer.apple.com/forums/thread/757040).
I've ported the change to ONNXRuntime and verified that:
* The issue is resolved in macOS 15 (all unit tests pass).
* The behaviour is unchanged in macOS 14. 


### Motivation and Context
This fixes microsoft#22275 allowing apps using ONNXRuntime with CoreML to work
normally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CoreML issues related to CoreML execution provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ONNXRuntime crashes on macOS 15 when using CoreML
4 participants