Open LittleLittleCloud opened 3 years ago
Is that behavior what you are generating? Or part of ML.NET itself? It seems likes its part of what model builder is generating.
It's the ml.net code generated by model builder. So I would say the behaviour is still mlnet's behaviours.
Sorry @LittleLittleCloud Ive been OOF. Back now. You said the behavior is to create a new context and prediction engine each time, correct? Thats not ML.NET, thats modelbuilder thats generating that code. The question is, is that whats causing the OOM? Or is there something in ML.NET that is doing it. Do you know what trainer he was using? Or what his pipeline looked like?
Ah, I just saw your second point. Only happens with TF.NET.
If you guys aren't calling dispose on the pipeline, or using a using
statement, then the native session won't be cleaned up correctly. How hard would that be to change in your code generation? Lets sync on this sometime. @JakeRadMSFT as well.
And no, creating new contexts/prediction engines is NOT the approach we recommend. Its a huge waste of time/resources. Much better to avoid that if possible.
This is an issue raised by model builder customer, who encountered an OOM exception after he creating an image classification model and call
Predict
method for hundreds of times. The behaviour ofPredict
method is take anModelInput
, create a new ml context and predict engine, and calculate theModelOutput
. So by callingPredict
method a hundred times, that user was creating a hundred ml contexts and predict engines. And finally, he found out the memory on his system ran out.There are actually two questions here
Link to original issue https://github.com/dotnet/machinelearning-modelbuilder/issues/1666