Core ML model initialization hangs with iOS 15

Hey;

I am having issues with a specific CoreML model's initialization under iOS 15

Specifically:

  • iOS 15 build 19A5318f on iPhone 11
  • App built with Xcode 13.0 (13A5212g) targeting iOS 13.0

The code basically looks like this

let configuration = MLModelConfiguration()
configuration.computeUnits = .all

let t0 = CACurrentMediaTime()
let model = try MyModelGeneratedClass(configuration: configuration).model
let t1 = CACurrentMediaTime()
print("Loading time: \(t1 - t0)")

When running that code I see a few errors in the console:

Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)
Error: Convolution configuration cannot fit in KMEM (Given: 258048b, Max: 65536b)

and then the app hangs, until finally

Loading time: 116.33786087499993"

(it always is around 2 minutes)

If I change the configuration so that

configuration.computeUnits = .cpuAndGPU

then everything works fine;

Did I miss something ? The CoreML SDK just hanging there for 2 minutes definitely looks like an iOS 15 bug

I just ran into the same thing. My guess is this is a bug in the CoreML compiler or on-device scheduler, where it tries to put part of the network onto the Neural Engine, even though it contains convolutions that need more memory than the Neural Engine can handle.

Core ML model initialization hangs with iOS 15
 
 
Q