0

Off on and for several months now, I've been trying and failing to build DL4J from source. I've even tried different distros, to no benefit. The closest I've come is using Ubuntu 19.10. mvn install -DskipTests works but the mvn clean test -P testresources,test-nd4j-native recommended at https://deeplearning4j.org/docs/latest/deeplearning4j-build-from-source produces the error below once the build gets to nd4j/nd4j-backends/nd4j-tests. The Ubuntu 19.10 is running on a VirtualBox with 28GB and 6 hyperthreads allocated to it.

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$1.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$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.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)

Michael Malak
  • 628
  • 8
  • 19
  • There is another exception that is the cause of that error. Make sure to run the build with `mvn -e -DtrimStackTrace=false ...` to get more messages. – Samuel Audet Dec 04 '19 at 00:36

1 Answers1

1

According to parameters you mentioned above, you are trying to build for CPU backend. To do that please use following command:

mvn -B -V -U clean install -Dmaven.test.skip=true

Also, make sure that you have installed all required build dependencies (jdk8, maven3, gcc7, cmake, python3)

If you really want to build and run tests, please use following commands:

  1. Clone and build dl4j-test-resources.

    git clone https://github.com/KonduitAI/dl4j-test-resources.git
    cd dl4j-test-resources
    mvn -B -V -U clean install
    
  2. Run tests command for CPU backend, but please note that some tests may fail at the moment.

    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
    
sshepel
  • 880
  • 1
  • 9
  • 16
  • Thanks, your second command is what I needed. With that, I'm currently getting `Failed tests: compareKeras[0: backend(org.nd4j.linalg.cpu.nativecpu.CpuBackend)={1}](org.nd4j.linalg.convolution.DeconvTests) Tests in error: testPad[0: backend(org.nd4j.linalg.cpu.nativecpu.CpuBackend)={1}](org.nd4j.autodiff.opvalidation.TransformOpValidation): Error calculating output shapes during op validation Tests run: 3704, Failures: 1, Errors: 1, Skipped: 155` ... but that appears to be a separate issue, so I am going to mark this as the solution. – Michael Malak Dec 06 '19 at 22:01