从源代码构建 DeepLearning4j:NoClassDefFoundError org.nd4j.linalg.factory.Nd4j
Building DeepLearning4j from source: NoClassDefFoundError org.nd4j.linalg.factory.Nd4j
几个月来,我一直在尝试从源代码构建 DL4J,但都失败了。我什至尝试过不同的发行版,但没有任何好处。我最接近的是使用 Ubuntu 19.10。 mvn install -DskipTests
有效,但在 https://deeplearning4j.org/docs/latest/deeplearning4j-build-from-source 推荐的 mvn clean test -P testresources,test-nd4j-native
会在构建达到 nd4j/nd4j-backends/nd4j-tests 时产生以下错误。 Ubuntu 19.10 在分配了 28GB 和 6 个超线程的 VirtualBox 上是 运行。
testSystemInfo(org.nd4j.systeminfo.TestSystemInfo) Time elapsed: 0.034 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.nd4j.linalg.factory.Nd4j
at org.nd4j.systeminfo.SystemInfo.getSystemInfo(SystemInfo.java:159)
at org.nd4j.systeminfo.SystemInfo.printSystemInfo(SystemInfo.java:419)
at org.nd4j.systeminfo.TestSystemInfo.testSystemInfo(TestSystemInfo.java:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
根据您上面提到的参数,您正在尝试为 CPU 后端构建。
为此,请使用以下命令:
mvn -B -V -U clean install -Dmaven.test.skip=true
此外,请确保您已安装所有必需的构建依赖项(jdk8、maven3、gcc7、cmake,python3)
如果您真的想要构建和 运行 测试,请使用以下命令:
克隆并构建 dl4j-test-resources。
git clone https://github.com/KonduitAI/dl4j-test-resources.git
cd dl4j-test-resources
mvn -B -V -U clean install
运行 测试 CPU 后端的命令,但请注意,目前某些测试可能会失败。
mvn -B -V -U test -DreuseForks=false -P native-snapshots -P test-nd4j-native -P nd4j-tests-cpu -P tf-cpu -P nd4j-tf-cpu -P testresources
几个月来,我一直在尝试从源代码构建 DL4J,但都失败了。我什至尝试过不同的发行版,但没有任何好处。我最接近的是使用 Ubuntu 19.10。 mvn install -DskipTests
有效,但在 https://deeplearning4j.org/docs/latest/deeplearning4j-build-from-source 推荐的 mvn clean test -P testresources,test-nd4j-native
会在构建达到 nd4j/nd4j-backends/nd4j-tests 时产生以下错误。 Ubuntu 19.10 在分配了 28GB 和 6 个超线程的 VirtualBox 上是 运行。
testSystemInfo(org.nd4j.systeminfo.TestSystemInfo) Time elapsed: 0.034 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.nd4j.linalg.factory.Nd4j
at org.nd4j.systeminfo.SystemInfo.getSystemInfo(SystemInfo.java:159)
at org.nd4j.systeminfo.SystemInfo.printSystemInfo(SystemInfo.java:419)
at org.nd4j.systeminfo.TestSystemInfo.testSystemInfo(TestSystemInfo.java:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
根据您上面提到的参数,您正在尝试为 CPU 后端构建。 为此,请使用以下命令:
mvn -B -V -U clean install -Dmaven.test.skip=true
此外,请确保您已安装所有必需的构建依赖项(jdk8、maven3、gcc7、cmake,python3)
如果您真的想要构建和 运行 测试,请使用以下命令:
克隆并构建 dl4j-test-resources。
git clone https://github.com/KonduitAI/dl4j-test-resources.git cd dl4j-test-resources mvn -B -V -U clean install
运行 测试 CPU 后端的命令,但请注意,目前某些测试可能会失败。
mvn -B -V -U test -DreuseForks=false -P native-snapshots -P test-nd4j-native -P nd4j-tests-cpu -P tf-cpu -P nd4j-tf-cpu -P testresources