Reputation: 1338
When trying to use any of Apple's CoreML tutorials (for example, this one), when the code initializes the model like so:
let model = try VNCoreMLModel(for: MobileNet().model)
I get the following error in the autogenerated code for the model (MobileNet.swift), on the last line of this segment:
let bundle = Bundle.main
let assetPath = bundle.url(forResource: "MobileNet", withExtension:"mlmodelc")
try! self.init(contentsOf: assetPath!)
Error: Thread 5: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}
Additionally, I get the following output in the console:
2018-06-23 15:46:27.216514-0700 Vision+ML Example[375:20287] [espresso] [Espresso::handle_ex_] exception=Metal device not found.
2018-06-23 15:46:27.328956-0700 Vision+ML Example[375:20287] [espresso] [Espresso::handle_ex_plan] exception=Error creating mps kernel
2018-06-23 15:46:27.329321-0700 Vision+ML Example[375:20287] [coreml] Error in adding network -1.
2018-06-23 15:46:27.347582-0700 Vision+ML Example[375:20287] [coreml] MLModelAsset: load failed with error Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}
2018-06-23 15:46:27.347759-0700 Vision+ML Example[375:20287] [coreml] MLModelAsset: modelWithError: load failed with error Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}
...and the app crashes.
What's going on here? I'm just running a tutorial from Apple's dev site, nothing else! (I'm testing on an iPhone 5s, iOS 12 beta 2, and am building on a MacBook Air running macOS 10.14 beta 2 with Xcode 10.0 beta 2)
Upvotes: 2
Views: 1302
Reputation: 31782
This seems like a bug. Ostensibly, the Vision and CoreML frameworks are supported on all devices that support iOS 11 (including iPhone 5s). I'd expect CoreML to fall back to BNNS or another codepath when one attempts to load a VNCoreMLModel
on a device without support for MetalPerformanceShaders (like iPhone 5s). It should at the very least produce an error message that explicitly states that this is unsupported, since there doesn't seem to be a capabilities key or free function that allows you to determine that this isn't supported.
I'd encourage you to file a bug report with all of the above details.
Upvotes: 3