MLModel crash app on init due to memory issue
Asked Answered
E

0

4

I'm seeing unexpected behavior with models I'm converting from Keras/TensorFlow/PyTorch etc.

When calling a simple init on an MLModel, without predicting or doing anything else, the app memory on some models spikes to 2-3GB.

self.myModel = MyModel(model: mlModel)

Even for a model that weighs less than a 1MB.

Also, playing with the MLModelConfiguration, changing the computeUnits seems to change the memory usage a bit, where .cpuOnly usually requires the least amount of memory.

But for the love of god, I have no idea why this is happening, is it something with the way I convert them? Specific layer that can cause it? Does anyone have a lead on how to tackle this?

This is the model we've converted: https://github.com/HasnainRaz/Fast-SRGAN

enter image description here

Evangelical answered 14/6, 2021 at 10:56 Comment(3)
Disclaimer: I AM NOT A MOBILE DEVELOPER. I am not sure about the reason it consumes so much CPU on code initiation but the best way is for you to use 3rd party codes to run some test and find the leak. towardsdatascience.com/…Gyroscope
I've seen this happen on certain models too, where some operation in the model seems to confuse Core ML. Very hard to diagnose. When Xcode 12 came out, it did something similar and the solution was to compile the model with Xcode 11. So who knows...Doss
Hey there, did you by any chance figure out the problem?Dearborn

© 2022 - 2024 — McMap. All rights reserved.