deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.13k stars 656 forks source link

Cannot find lightgbm library #2174

Closed KexinFeng closed 1 year ago

KexinFeng commented 1 year ago

Description

When running djl/integration/src/test/java/ai/djl/integration/IntegrationTests.java with lightgbm, it fails with error: ai.djl.engine.EngineException: Cannot load library: lib_lightgbm.dylib Running gradle :engines:ml:lightgbm:build also report error: ai.djl.engine.EngineException: Cannot load library: lib_lightgbm.dylib

This seems to have happened before.

Maybe this is because the lightgbm needs compilation?

Error message:

ai.djl.engine.EngineException: Cannot load library: lib_lightgbm.dylib
    at app//ai.djl.ml.lightgbm.jni.LibUtils.loadNative(LibUtils.java:81)
    at app//ai.djl.ml.lightgbm.jni.LibUtils.loadNative(LibUtils.java:49)
    at app//ai.djl.ml.lightgbm.LgbmEngine.<init>(LgbmEngine.java:44)
    at app//ai.djl.ml.lightgbm.LgbmEngine.newInstance(LgbmEngine.java:51)
    at app//ai.djl.ml.lightgbm.LgbmEngineProvider.getEngine(LgbmEngineProvider.java:39)
    at app//ai.djl.engine.Engine.getEngine(Engine.java:184)
    at app//ai.djl.Model.newInstance(Model.java:99)
    at app//ai.djl.repository.zoo.BaseModelLoader.createModel(BaseModelLoader.java:189)
    at app//ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:152)
    at app//ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:168)
    at app//ai.djl.ml.lightgbm.LgbmModelTest.testLoad(LgbmModelTest.java:53)
    at java.base@11.0.14.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base@11.0.14.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base@11.0.14.1/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base@11.0.14.1/java.lang.reflect.Method.invoke(Method.java:566)
    at app//org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
    at app//org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:673)
    at app//org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220)
    at app//org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
    at app//org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945)
    at app//org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193)
    at app//org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at app//org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.base@11.0.14.1/java.util.ArrayList.forEach(ArrayList.java:1541)
    at app//org.testng.TestRunner.privateRun(TestRunner.java:808)
    at app//org.testng.TestRunner.run(TestRunner.java:603)
    at app//org.testng.SuiteRunner.runTest(SuiteRunner.java:429)
    at app//org.testng.SuiteRunner.runSequentially(SuiteRunner.java:423)
    at app//org.testng.SuiteRunner.privateRun(SuiteRunner.java:383)
    at app//org.testng.SuiteRunner.run(SuiteRunner.java:326)
    at app//org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at app//org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
    at app//org.testng.TestNG.runSuitesSequentially(TestNG.java:1249)
    at app//org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at app//org.testng.TestNG.runSuites(TestNG.java:1092)
    at app//org.testng.TestNG.run(TestNG.java:1060)
    at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.runTests(TestNGTestClassProcessor.java:146)
    at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:91)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at java.base@11.0.14.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base@11.0.14.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base@11.0.14.1/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base@11.0.14.1/java.lang.reflect.Method.invoke(Method.java:566)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy5.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
    at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.UnsatisfiedLinkError: /Users/fenkexin/.djl.ai/lightgbm/lib_lightgbm.dylib: dlopen(/Users/fenkexin/.djl.ai/lightgbm/lib_lightgbm.dylib, 0x0001): Library not loaded: '/usr/local/opt/libomp/lib/libomp.dylib'
  Referenced from: '/Users/fenkexin/.djl.ai/lightgbm/lib_lightgbm.dylib'
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    at java.base/java.lang.Runtime.load0(Runtime.java:768)
    at java.base/java.lang.System.load(System.java:1837)
    at ai.djl.ml.lightgbm.jni.LibUtils.loadNative(LibUtils.java:79)
    ... 56 more
KexinFeng commented 1 year ago

Solved by installing 'libomp.dylib' via brew install libomp (on MacOS).