dotnet / dotnet/machinelearning

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

Open
#7,226 0 comments 0 reactions 0 assignees View on GitHub
area-Native untriaged
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

**System Information (please complete the following information):**
- Windows 10
- ML.NET Version: 3.0.1
- Api Compatibility Level - .Net FrameWork
- VS 2022 17.11.2
- NuGet for Unity 4.1.1

**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
4. 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](https://github.com/user-attachments/assets/03386ff6-2f94-4eaf-961a-4891c62167ca)
Dlls import settings
![image](https://github.com/user-attachments/assets/74831d70-b896-4399-8d2e-dd19f53e44be)

**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](https://github.com/dotnet/machinelearning/issues/5760#issue-865040147), but the CpuMathNative.dll is actually missing in the last version of Microsoft.ML.CpuMath.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.