Skip to content

Commit

Permalink
Fixes a crash on macOS 15 when using CoreML. (#22277)
Browse files Browse the repository at this point in the history
### 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 #22275 allowing apps using ONNXRuntime with CoreML to work
normally.
  • Loading branch information
marovira authored Oct 1, 2024
1 parent ee7081b commit ffca096
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/coreml/model/model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Status Predict(const std::unordered_map<std::string, OnnxTensorData>& inputs,

compiled_model_path_ = [compileUrl path];

MLModelConfiguration* config = [MLModelConfiguration alloc];
MLModelConfiguration* config = [[MLModelConfiguration alloc] init];
config.computeUnits = (coreml_flags_ & COREML_FLAG_USE_CPU_ONLY)
? MLComputeUnitsCPUOnly
: MLComputeUnitsAll;
Expand Down

0 comments on commit ffca096

Please sign in to comment.