Skip to content

Unable to load DLL 'CpuMathNative': The specified module could not be found #5495

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

Closed
BalsamIbrahim opened this issue Nov 18, 2020 · 15 comments
Closed

Comments

@BalsamIbrahim
Copy link

salam all
I face this problem when I use Microsoft.ML to create clustering
I hope to help me
System.DllNotFoundException: 'Unable to load DLL 'CpuMathNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'
thank you
image

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim Thanks for using ML.NET, could you please provide a repro project so we can investigate further?

@BalsamIbrahim
Copy link
Author

@frank-dong-ms
project type : Class Library
Target : 4.6.1
what I do : I have list from Latitude and longitude and I need do clustering for them in my plugin

@BalsamIbrahim
Copy link
Author

BalsamIbrahim commented Nov 18, 2020

this my code 
        public void cluster (List<Entity> prescriptions , int total_seconds_allowed, int iteration)
        {
            try
            {
                var max = prescriptions.Count / 3;
                max = total_seconds_allowed > 3600 ? max * 2 : max;
                var max_clusters = max + iteration;
                max_clusters = max_clusters > prescriptions.Count ? prescriptions.Count : max_clusters;

                var listpoints = new List<InputDate>();
               //prescriptions.ForEach(item => listpoints.Add( new InputDate { Feature1 =item.GetAttributeValue<decimal>("new_latitude"), Feature2 = item.GetAttributeValue<decimal>("new_longitude") }));
               // listpoints = listpoints.Where(c => c.Feature1 != 0 && c.Feature2 != 0).ToList();
              
                List<InputDate> pointsValues = prescriptions
                    .Select(value => { return new InputDate(value.GetAttributeValue<decimal>("new_longitude"), value.GetAttributeValue<decimal>("new_latitude")); })
                    .ToList();
                var mlContext = new MLContext();
       
                IDataView dataView = mlContext.Data.LoadFromEnumerable(pointsValues);
                var options = new KMeansTrainer.Options
                {
                    NumberOfClusters = max_clusters,
                    OptimizationTolerance = 1e-6f,
                    NumberOfThreads = 1,InitializationAlgorithm = KMeansTrainer.InitializationAlgorithm.Random,FeatureColumnName = "Features"  
                };
                var pipeline = mlContext.Transforms.Concatenate(
                    "Features",
                    "Latitude", 
                    "Longitude")
                    .Append(mlContext.Clustering.Trainers.KMeans(options));

                var model = pipeline.Fit(dataView);
            }
            catch (Exception ex)
            {

                throw;
            }
            

        }
        public class InputDate
        {
            [LoadColumn(0)]
            public float Latitude;
            [LoadColumn(1)]
            public float Longitude;
            [LoadColumn(2)]
            public string Label;
            public InputDate(decimal longitude, decimal latitude)
            {
                Latitude = Convert.ToSingle(latitude) ;
                Longitude = Convert.ToSingle(longitude);
            }
        }

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim Thanks, could you please provide a complete repro project or solution, and your repro steps? Previous code piece is not enough for me to investigate the issue. Also, the missing DLL 'CpuMathNative' is coming from nuget package 'Microsoft.ML.CpuMath', you can find this dll under path 'runtimes\win-x64\nativeassets\netstandard2.0\CpuMathNative.dll', could you verify if the nuget package contains that dll?

@BalsamIbrahim
Copy link
Author

BalsamIbrahim commented Nov 18, 2020

okay because I speak Arabic not English so please can you afford me ??
I'll upload some picture
references
image
packages
image

I am now briefly clarifying the project
First I have a group of packages for people
They are receive through the driver
Objective: To give the driver the best route to deliver all packages to people
From points I want to create the best path using the microsoft.ML

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim are you able to provide the whole/complete project?

@BalsamIbrahim
Copy link
Author

@frank-dong-ms YES I HAVE COMPLETE PROJECT
I'LL COMPRESS PROJECT AND UPLOAD IT

@BalsamIbrahim
Copy link
Author

BalsamIbrahim commented Nov 18, 2020

class name Scheduale

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim Thanks I can reproduce your issue and I will start to work on a fix.

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim If possible you can use dotnet core for your class library project Plugin and your issue will go away if you use dotnet core.

@BalsamIbrahim
Copy link
Author

okay, I try use .net core but I face problem in this
image
this plugins use frame work

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim is it possible to change the Plugin project to use .net core?

@frank-dong-ms-zz
Copy link
Contributor

@BalsamIbrahim another work around is to add package reference of Microsoft.ML.CpuMath to the project consuming the plugin project and set x64 for both Debug and Release:
#4870 (comment)

@BalsamIbrahim
Copy link
Author

@BalsamIbrahim another work around is to add package reference of Microsoft.ML.CpuMath to the project consuming the plugin project and set x64 for both Debug and Release:
#4870 (comment)

it's work thanks

@frank-dong-ms-zz
Copy link
Contributor

Close this issue now, feel free to reopen if any necessary.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants