dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.93k stars 1.86k forks source link

converted onnx model takes much more load time and memory size. #6932

Closed NofAssiri closed 4 months ago

NofAssiri commented 6 months ago

System information

Issue

i have ml.net model of size 47MB (zipped) it loads in 1 second and takes about 100, 150MB of memory, but when i convert it to onnx format using ConvertToOnnx function and empty list of input data type, now the model size 112MB, loads in 6 seconds and takes about 2GB of memory

Source code / logs

conversion code var dummy = new List(); var dummyData = _ctx.Data.LoadFromEnumerable(dummy); using (var onnx = File.Open("C:\models\onnModel.onnx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { _ctx.Model.ConvertToOnnx(transformer, dummyData, onnx); }

load code var ctx =new MLContext(); var model = ctx.transform.ApplyOnnxModel("C:\models\onnxModel.onnx");

michaelgsharp commented 5 months ago

Are you able to upload the model/data/repro project so we can take a look at it?

ghost commented 5 months ago

This issue has been marked needs-author-action and may be missing some important information.

ghost commented 5 months ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

ghost commented 4 months ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.