dotnet / machinelearning

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

Integrating ML.Net 3.0.1 into Unity 2022.3.28f1 causes "DllNotFoundExeption: CpuMathNative" #7226

Open Tatyana-Stoyanova opened 2 months ago

Tatyana-Stoyanova commented 2 months ago

System Information (please complete the following information):

Describe the bug Trying to fit the model causes DllNotFoundException: CpuMathNative error in the console.

To Reproduce Steps to reproduce the behavior:

  1. Install Microsoft.ML(3.0.1) and System.Runtime.CompilerServices.Unsafe(6.0.0) using NuGet for Unity. (other dependencies are automatically installed - such as Microsoft.ML.CpuMath.3.0.1, Microsoft.ML.DataView.3.0.1, System.Memory.4.5.5, System.Numerics.Tensors.8.0.0)
  2. Create TextLoader to read data from csv file, make a pipeline to preprocess data and fit the model
  3. See error

Expected behavior The fiting must create a model that is ready to be used for evaluetion and prediction.

Actual behaviour (In Editor) "DllNotFoundExceptionL CpuMathNative ... "

Screenshots, Code, Sample Projects image Dlls import settings image

Additional context The bug is duplicate of #6741. The proposed solution https://github.com/dotnet/machinelearning/issues/6741#issuecomment-1612111915 by @luisquintanilla does not fix the issue, because in the Microsoft.ML.CpuMath package that was importet as Nuget there was no CPUMathNative.dll, only Microsoft.ML.CPUMath.dll. Actually the problem was solved with copying of the missing dll from the Minimal ML Test example posted on following issue: MLContext.Data.LoadFromEnumerable() not working in Unity for netstandard2.0 api, but the CpuMathNative.dll is actually missing in the last version of Microsoft.ML.CpuMath.