I ran into this problem too.
I used CoreML to do a simple image classification. I tested it on the following hardware.
M1 Pro MacBook Pro 16 16G
M1 iMac 24 16G
intel MacBook Pro 13 16G
iPhone 13 mini
As a result of the verification, the following problems occurred only with M1Pro.
H11ANEDevice::H11ANEDeviceOpen kH11ANEUserClientCommand_DeviceOpen call failed result=0xe00002bc
Error opening LB - status=0xe00002bc.. Skipping LB and retrying
So I also compared the execution speed and got the following results.
M1 Pro(74s)
M1 (52s)
As shown above, the M1 was 42% faster than the M1Pro.
My codes is like this:
import Foundation
import Vision
import CoreML
import CoreImage
class MacInference{
private let model = try? testml(configuration: MLModelConfiguration()).model //CoreML model
var TopResultConfidence : Float = 0.0
var TopResultId = ""
var debug = false
private func checkFile(fileURL : String) -> Bool{
let filePath = fileURL.replacingOccurrences(of: "file://", with: "")
if FileManager.default.fileExists(atPath: filePath) {
return true
}else{
return false
}
}
func startML(fileURL : String){
let coreMLModel = try? VNCoreMLModel(for: self.model!)
let request = VNCoreMLRequest(model: coreMLModel!){ request, error in
if let results = request.results as? [VNClassificationObservation]{
self.TopResultConfidence = results[0].confidence
self.TopResultId = results[0].identifier
if self.debug {
for result in results {
print(result.confidence * 100, result.identifier)
}
}
}
}
if !self.checkFile(fileURL: fileURL){
print("URL error")
return
}
let ciimage = CIImage(contentsOf: URL(string: fileURL)!)
let handler = VNImageRequestHandler(ciImage: ciimage!, options: [:])
do {
try handler.perform([request])
} catch {
print(error)
}
}
}
let macML = MacInference()
macML.debug = true
macML.startML(fileURL: "FILE URL")
Topic:
Machine Learning & AI
SubTopic:
General
Tags: