LightGBM fails to run on OS X unless libomp is installed.
A change 6 days ago added the requirement for libomp and we haven't updated the build instructions or build script.
Error:
Unexpected exception: Unable to load shared library 'lib_lightgbm' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblib_lightgbm, 1): image not found, 'System.DllNotFoundException'
at Microsoft.ML.Runtime.LightGBM.WrappedLightGbmInterface.DatasetCreateFromSampledColumn(IntPtr sampleValuePerColumn, IntPtr sampleIndicesPerColumn, Int32 numCol, Int32[] sampleNonZeroCntPerColumn, Int32 numSampleRow, Int32 numTotalRow, String parameters, IntPtr& ret)
at Microsoft.ML.Runtime.LightGBM.Dataset..ctor(Double[][] sampleValuePerColumn, Int32[][] sampleIndicesPerColumn, Int32 numCol, Int32[] sampleNonZeroCntPerColumn, Int32 numSampleRow, Int32 numTotalRow, String param, Single[] labels, Single[] weights, Int32[] groups) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.LightGBM/WrappedLightGbmDataset.cs:line 45
at Microsoft.ML.Runtime.LightGBM.LightGbmTrainerBase`3.CreateDatasetFromSamplingData(IChannel ch, Factory factory, Int32 numRow, String param, Single[] labels, Single[] weights, Int32[] groups, CategoricalMetaData catMetaData, Dataset& dataset) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs:line 660
at Microsoft.ML.Runtime.LightGBM.LightGbmTrainerBase`3.LoadTrainingData(IChannel ch, RoleMappedData trainData, CategoricalMetaData& catMetaData) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs:line 343
at Microsoft.ML.Runtime.LightGBM.LightGbmTrainerBase`3.TrainModelCore(TrainContext context) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.LightGBM/LightGbmTrainerBase.cs:line 103
at Microsoft.ML.Runtime.Training.TrainerEstimatorBase`2.Microsoft.ML.Runtime.ITrainer.Train(TrainContext context) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.Data/Training/TrainerEstimatorBase.cs:line 155
at Microsoft.ML.Runtime.Data.TrainUtils.TrainCore(IHostEnvironment env, IChannel ch, RoleMappedData data, ITrainer trainer, RoleMappedData validData, ICalibratorTrainer calibrator, Int32 maxCalibrationExamples, Nullable`1 cacheData, IPredictor inputPredictor) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.Data/Commands/TrainCommand.cs:line 259
at Microsoft.ML.Runtime.Data.CrossValidationCommand.FoldHelper.RunFold(Int32 fold) in /Users/justinormont/Documents/Microsoft/src/machinelearning/src/Microsoft.ML.Data/Commands/CrossValidationCommand.cs:line 551
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
On OS X, we can install libomp:
$ brew install libomp
brew install libomplibomp and fail the build if missinglibomp if missing--installing global system software during a build is bad though; is there a way to do a local install? libomp and produce a helpful error--this issue affects nuget users ; perhaps a change to the upstream LightGBM (@guolinke, thoughts?)We should check if the libomp requirement increases the difficultly to distribute apps which call into ML.NET. Do the end-users (or the apps install script) have to install libomp?
Thanks to @eerhardt for finding the brew install libomp solution and providing much of the above background information.
My opinion is that we should do all of the following steps (sorted in easy-to-hard order):
brew install libomplibomp installed globally on the machine.libomp along with either LightGBM proper, or shipping it with our Microsoft.ML.LightGBM wrapper NuGet package.Doing (2) above would help even when running the tests or trying to use LightGBM as a user. If we had a good error message that said You're trying to use LightGBM, but it couldn't be loaded. Do you have the all dependencies installed? See aka.ms/mlnetLightGBM.
I wouldn't update the build script to install global software on the machine. I think mutating machine state in that way is surprising to developers. Pulling down local copies of software into the repo is different than installing something into the equivalent of "Program Files". You also may need to run the build as sudo, which is not a great expectation.
Update our build script to check for libomp and fail the build if missing
I would vote against this because there are users who just want to build the repo, and use other bits that aren't LightGBM. Forcing them to install software that they aren't going to use isn't a great experience IMO.
I would recommend an error message (and related test) which gets the user to the solution faster. Perhaps, Error: LightGBM requires libomp which can be installed by running 'brew install libomp'. Sending them to a "have you checked the requirements" page sounds, to me, slightly passive aggressive and I think we could provide a directly actionable message.
This extra user-orientated convince has _trade-offs_, for instance we have to specifically check for libopm to know that's the issue (and not a simpler to detect 'LightGBM failed to load' error), and we have to alter the output text depending on platform. One upside is not having to maintain another aka.ms link.
For the build script error: Generally when I build software, I expect all parts which I build to work. If they build LightGBM I think they also expect it to be usable.
@justinormont , is this about documentation update? Is this fixed already?
@Zruty0: This is still an open issue. @eerhardt and I have some recommendations/proposals above for methods to fix.
HI,
I have deployed the application using dot net core 3.0 "Self Contained" profile on a new windows 2019 sever and have the same error. It's not limited to IOS.
The build script does install libiomp 7.0 as evident from here , however we need to updated documentation for people using nugets that depend on mkl which depends on libiomp that they need libiomp v7.0
Most helpful comment
I would recommend an error message (and related test) which gets the user to the solution faster. Perhaps,
Error: LightGBM requires libomp which can be installed by running 'brew install libomp'. Sending them to a "have you checked the requirements" page sounds, to me, slightly passive aggressive and I think we could provide a directly actionable message.This extra user-orientated convince has _trade-offs_, for instance we have to specifically check for
libopmto know that's the issue (and not a simpler to detect 'LightGBM failed to load' error), and we have to alter the output text depending on platform. One upside is not having to maintain another aka.ms link.For the build script error: Generally when I build software, I expect all parts which I build to work. If they build LightGBM I think they also expect it to be usable.