Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading time of 2MB ML model is significantly slower in .NET Core compared to .NET Framework #5913

Open
martintomasek opened this issue Aug 25, 2021 · 2 comments
Labels
bug Something isn't working loadsave Bugs related loading and saving data or models

Comments

@martintomasek
Copy link
Contributor

System Information (please complete the following information):

  • OS & Version: Windows 10
  • ML.NET Version: ML.NET v1.6
  • .NET Version: .NET Core 3.1, .NET 5.0

Describe the bug
We have approx 2MB trained ML model for binary classification. When we are loading model it takes to load it 2s in average on .NET 5. When we run on .NET Framework, it takes only 0,5s.

To Reproduce
Steps to reproduce the behavior:

  1. Load bigger ML model with method "mlContext.Model.Load()"

Expected behavior
Model loading time should be similar like in .NET Framework

Screenshots, Code, Sample Projects

		private static PredictionEngine<ModelInput, ModelOutput> GetPredEngine()
		{
			MLContext mlContext = new MLContext();

			// Load model & create prediction engine
			ITransformer mlModel = mlContext.Model.Load(MLNetModelPath, out var modelInputSchema);
			var predEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
			return predEngine;
		}

Additional context
When I add BufferedStream for loading from DeflateStream in BinaryLoader, it looks the issue is solved.
BinaryLoader commit
I could do a pull request.

@michaelgsharp michaelgsharp added bug Something isn't working loadsave Bugs related loading and saving data or models labels Sep 2, 2021
@michaelgsharp
Copy link
Member

This is very interesting. Thanks for doing the testing and figuring out the issue. You commit looks good to me but I'll do some more testing.

@eerhardt is this slowdown a known issue between .NET Framework and .NET Core? Or do you think something else is maybe at play here?

@eerhardt
Copy link
Member

eerhardt commented Sep 2, 2021

Might be related to dotnet/runtime#39233? Looks super similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working loadsave Bugs related loading and saving data or models
Projects
None yet
Development

No branches or pull requests

3 participants