Closed
Description
System information
- OS version/distro: Windows
- .NET Version (eg., dotnet --info):
> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.400-preview-009063
Commit: dd0179a67c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.400-preview-009063\
Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684
Issue
- What did you do?
Using the latest0.3.0-preview
NuGet package, I tried using LightGBM in a .NET Core application. I did the walk through: https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows, only changing:
// STEP 4: Add learner
// Add a learning algorithm to the pipeline.
// This is a classification scenario (What type of iris is this?)
pipeline.Add(new LightGbmClassifier());
// pipeline.Add(new StochasticDualCoordinateAscentClassifier());
- What happened?
Unhandled Exception: System.InvalidOperationException: Entry point 'Trainers.LightGbmClassifier' not found
at Microsoft.ML.Runtime.EntryPoints.EntryPointNode..ctor(IHostEnvironment env, IChannel ch, ModuleCatalog moduleCatalog, RunContext context, String id, String entryPointName, JObject inputs, JObject outputs, Boolean checkpoint, String stageId, Single cost, String label, String group, String weight)
at Microsoft.ML.Runtime.EntryPoints.EntryPointNode.ValidateNodes(IHostEnvironment env, RunContext context, JArray nodes, ModuleCatalog moduleCatalog, String label, String group, String weight)
at Microsoft.ML.Runtime.EntryPoints.EntryPointGraph..ctor(IHostEnvironment env, ModuleCatalog moduleCatalog, JArray nodes)
at Microsoft.ML.Runtime.Experiment.Compile()
at Microsoft.ML.LearningPipeline.Train[TInput,TOutput]()
at MLLightGBMSmokeTest.Program.Main(String[] args) in C:\Users\eerhardt\source\repos\MLLightGBMSmokeTest\Program.cs:line 72
- What did you expect?
I expected the walk through app to run successfully.
Notes
When F5 debugging a .NET Core app in VS, or using dotnet run
on the command line, .NET Core doesn't have all the dependencies copied to the output directory. Instead, references that come from NuGet packages are executed from the NuGet package cache folder.
Since LightGBM comes from a separate NuGet package than the rest of the Microsoft.ML, it is loaded from a separate folder than the rest of the Microsoft.ML package.
I've looked through the ComponentCatalog code, and it appears if I force the Microsoft.ML.LightGBM.dll
to be loaded first, I can workaround the issue.
So I added
static void Main(string[] args)
{
// workaround to ensure LightGbm assembly is loaded
new LightGbmArguments();
And I am able to successfully use LightGBM on .NET Core during F5.
Workarounds
Any of these should allow you to workaround the issue:
- forcing the assembly to be loaded, like I did above:
new LightGbmArguments();
dotnet publish
your application and running it from the published folder (since all dependencies are copied during publish)- Using full .NET Framework