Skip to content

ML.FastTree nuget package doesn't work with packages.config #3626

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
eerhardt opened this issue Apr 30, 2019 · 8 comments · Fixed by #3628
Closed

ML.FastTree nuget package doesn't work with packages.config #3626

eerhardt opened this issue Apr 30, 2019 · 8 comments · Fixed by #3628

Comments

@eerhardt
Copy link
Member

Try using Microsoft.ML.FastTree on .NET Framework using packages.config.

You get an exception:

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'FastTreeNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.ML.Trainers.FastTree.DenseIntArray.C_Sumup_double(Int32 numBits, Byte* pData, Int32* pIndices, Double* pSampleOutputs, Double* pSampleOutputWeights, Double* pSumTargetsByBin, Double* pSumTargets2ByBin, Int32* pCountByBin, Int32 totalCount, Double totalSampleOutputs, Double totalSampleOutputWeights)
   at Microsoft.ML.Trainers.FastTree.DenseIntArray.SumupCPlusPlusDense(SumupInputData input, FeatureHistogram histogram, Byte* data, Int32 numBits)
   at Microsoft.ML.Trainers.FastTree.Dense8BitIntArray.Sumup(SumupInputData input, FeatureHistogram histogram)
   at Microsoft.ML.Trainers.FastTree.FeatureHistogram.SumupWeighted(Int32 numDocsInLeaf, Double sumTargets, Double sumWeights, Double[] outputs, Double[] weights, Int32[] docIndices)

This is because we aren't copying the FastTreeNative.dll to the output folder.

We should be including https://github.com/dotnet/machinelearning/blob/master/pkg/common/CommonPackage.props in the nuget package, and this would start working.

@shauheen @glebuk @TomFinley

@shauheen
Copy link
Contributor

Thanks @eerhardt for filing and fixing :)

eerhardt added a commit to eerhardt/machinelearning that referenced this issue Apr 30, 2019
The FastTree NuGet package is currently broken on .NET Framework when using packages.config because we are not copying the native files to the output folder.

Fix dotnet#3626
eerhardt added a commit to eerhardt/machinelearning that referenced this issue Apr 30, 2019
The FastTree NuGet package is currently broken on .NET Framework when using packages.config because we are not copying the native files to the output folder.

Fix dotnet#3626
shauheen pushed a commit that referenced this issue Apr 30, 2019
The FastTree NuGet package is currently broken on .NET Framework when using packages.config because we are not copying the native files to the output folder.

Fix #3626
shauheen pushed a commit that referenced this issue Apr 30, 2019
The FastTree NuGet package is currently broken on .NET Framework when using packages.config because we are not copying the native files to the output folder.

Fix #3626
@alex-resdiary
Copy link

I am using ML.Net.FastTree and i keep running into this issue even after re-installing the package :
Unable to load DLL 'FastTreeNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Any ideas on how to solve this issue?

@eerhardt
Copy link
Member Author

@alex-resdiary - could you give a little more information on your project? (If you could zip up your project and send it to me, that would be easiest. My email is in my github profile.)

Are you targeting .NET Framework or .NET Core? Are you using packages.config? If you are targeting .NET Framework and packages.config, are you building for x64?

@jtsoftware
Copy link

I'm seeing the same problem.
.NET Framework 4.7.2
ML .NET 1.7.9
Using package.config
All CPUs or x64.

I'll send you a repro solution.

The exception info:

System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
at Microsoft.ML.Trainers.FastTree.ThreadTaskManager.ThreadTask.RunTask()
at Microsoft.ML.Trainers.FastTree.LeastSquaresRegressionTreeLearner.FindBestSplitOfRoot(Double[] targets)
at Microsoft.ML.Trainers.FastTree.LeastSquaresRegressionTreeLearner.FitTargets(IChannel ch, Boolean[] activeFeatures, Double[] targets)
at Microsoft.ML.Trainers.FastTree.RandomForestLeastSquaresTreeLearner.FitTargets(IChannel ch, Boolean[] activeFeatures, Double[] weightedtargets, Double[] targets, Double[] weights)
at Microsoft.ML.Trainers.FastTree.RandomForestOptimizer.TrainingIteration(IChannel ch, Boolean[] activeFeatures)
at Microsoft.ML.Trainers.FastTree.FastTreeTrainerBase3.Train(IChannel ch) at Microsoft.ML.Trainers.FastTree.FastTreeTrainerBase3.TrainCore(IChannel ch)
at Microsoft.ML.Trainers.FastTree.FastForestBinaryTrainer.TrainModelCore(TrainContext context)
at Microsoft.ML.Trainers.TrainerEstimatorBase2.TrainTransformer(IDataView trainSet, IDataView validationSet, IPredictor initPredictor) at Microsoft.ML.Trainers.TrainerEstimatorBase2.Fit(IDataView input)
at Microsoft.ML.Data.EstimatorChain1.Fit(IDataView input) at MTCWordPredictionModel.Base.ModelTrainerBase.Fit(String inputFilePath) in F:\Repros\FatTreeNativeProblem\MTCWordPredictionModel\Base\ModelTrainerBase.cs:line 62 at MTCWordPredictionModel.Test.LocalModelTest.Train(IModelTrainerBase trainer) in F:\Repros\FatTreeNativeProblem\MTCWordPredictionModel\Test\LocalModelTest.cs:line 59 at MTCWordPredictionModel.Test.LocalModelTest.<RunTest>b__17_0(IModelTrainerBase t) in F:\Repros\FatTreeNativeProblem\MTCWordPredictionModel\Test\LocalModelTest.cs:line 48 at System.Collections.Generic.List1.ForEach(Action`1 action)
at MTCWordPredictionModel.Test.LocalModelTest.RunTest(String trainingFilePath, String testFilePath, String outputFilePath, String modelFilePath) in F:\Repros\FatTreeNativeProblem\MTCWordPredictionModel\Test\LocalModelTest.cs:line 48
at FatTreeNativeProblem.Program.Main(String[] args) in F:\Repros\FatTreeNativeProblem\FatTreeNativeProblem\Program.cs:line 21

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
DllNotFoundException: Unable to load DLL 'FastTreeNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

@eerhardt
Copy link
Member Author

Is the .dll in the output folder?

@jtsoftware
Copy link

jtsoftware commented Jan 20, 2022 via email

@eerhardt
Copy link
Member Author

The issue with your project is that you are using packages.config and a ProjectReference from your "app" project to your "library" project. With packages.config, the NuGet dependencies aren't transitive, like they are with PackageReference. My suggestion is to convert your project to use PackageReference instead of packages.config. See https://docs.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference.

Alternatively, if you want to continue using packages.config, you need to install the Microsoft.ML.FastTree package in the "app"/ "exe" project.

@jtsoftware
Copy link

Thanks. Got it. I thought Visual Studio copied dependent DLLs, but I guess the FastTreeNative.dll is loaded dynamically, so VS didn't know about it.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 22, 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.

4 participants