Compiling on ARM

I’m tring to compile the source code on ARM server.
The enviroment is same with Run on ARM cpu server .
The source code is downloaded from github at 2020-03-16.

There are 2 problems.

  1. detect OS to ‘linux’
    At line 174 in libnd4j/buildnativeoperations.sh:
    case “$OS” in
    the value of $OS is 'linux", result in the value of $ARCH is 'x86-64", which is wrong.
    I set the value of $OS to ‘linux-arm64’ by hand to solve it.
  2. scalar error
    The compiling log:

Could not find OpenBLAS, please make sure to run the build with Maven or set the OPENBLAS_PATH variable
!!!
!! !!
!! !!
!! !!
!! !!
!! WARNING! !!
!! No helper packages configured! !!
!! You can specify helper by using -h key. I.e. <-h mkldnn> !!
!! !!
!! !!
!! !!
!! !!
!!!
PACKAGING = none
BUILD = release
CHIP = cpu
ARCH = armv8-a
CHIP_EXTENSION =
CHIP_VERSION =
GPU_COMPUTE_CAPABILITY = all
EXPERIMENTAL = no
LIBRARY TYPE = dynamic
OPERATIONS = -DLIBND4J_ALL_OPS=true
MINIFIER = -DLIBND4J_BUILD_MINIFIER=false
TESTS = -DBUILD_TESTS=OFF
NAME = -DLIBND4J_NAME=nd4jcpu
OPENBLAS_PATH =
CHECK_VECTORIZATION = OFF
HELPERS =
/dl4j/libnd4j/blasbuild/cpu
Original library: /usr/local/lib/libopenblas.a
Found external BLAS implementation: /usr/local/lib/libopenblas.a
– Configuring done
– Generating done
– Build files have been written to: /dl4j/libnd4j/blasbuild/cpu/flatbuffers-download
[ 11%] Performing update step for ‘flatbuffers’
[ 22%] No configure step for ‘flatbuffers’
[ 33%] No build step for ‘flatbuffers’
[ 44%] No install step for ‘flatbuffers’
[ 55%] No test step for ‘flatbuffers’
[ 66%] Completed ‘flatbuffers’
[100%] Built target flatbuffers
CMake Warning at blasbuild/cpu/flatbuffers-src/CMakeLists.txt:21 (message):
Cannot build tests without building the compiler. Tests will be disabled.

NOT CLION
CPU BLAS
– Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
– Could NOT find OpenMP (missing: OpenMP_CXX_FOUND)
– Configuring done
– Generating done
– Build files have been written to: /dl4j/libnd4j/blasbuild/cpu
[ 1%] Building CXX object blas/CMakeFiles/nd4jobj.dir//include/loops/impl/type_conversions.cpp.o
[ 1%] Building CXX object blas/CMakeFiles/nd4jobj.dir/
/include/loops/cpu/transform/transform_strict.cpp.o
[ 1%] Building CXX object blas/CMakeFiles/nd4jobj.dir//include/loops/cpu/scalar_int.cpp.o
[ 1%] Building CXX object blas/CMakeFiles/nd4jobj.dir/
/include/loops/cpu/transform/transform_same.cpp.o
during RTL pass: expand
/dl4j/libnd4j/include/loops/cpu/scalar_int.cpp: In static member function ‘static void functions::scalar::ScalarIntTransform::transform(int, void, Nd4jLong, void, Nd4jLong, void*, void*, uint64_t, uint64_t, uint64_t) [with X = long unsigned int]’:**
/dl4j/libnd4j/include/loops/cpu/scalar_int.cpp:207:25: internal compiler error: in expand_shift_1, at expmed.c:2631
** z[i] = OpType::op(x[i], scalar, extraParams);**
** ^**
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
make[2]: *** [blas/CMakeFiles/nd4jobj.dir/build.make:1688: blas/CMakeFiles/nd4jobj.dir/__/include/loops/cpu/scalar_int.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [CMakeFiles/Makefile2:198: blas/CMakeFiles/nd4jobj.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
buildmultiplescalaversions.sh: line 38: ./change-scala-versions.sh: No such file or directory
./compileDl4j.sh: 31: [: unexpected operator
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects…
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-library:jar is missing. @ line 40, column 22
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-library:jar is missing. @ line 88, column 22
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-reflect:jar is missing. @ line 94, column 22
@
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]
[ERROR] The project org.datavec:datavec-spark_2.11:1.0.0-SNAPSHOT (/dl4j/datavec/datavec-spark/pom.xml) has 1 error
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-library:jar is missing. @ line 40, column 22
[ERROR]
[ERROR] The project org.datavec:datavec-spark-inference-server_2.11:1.0.0-SNAPSHOT (/dl4j/datavec/datavec-spark-inference-parent/datavec-spark-inference-server/pom.xml) has 2 errors
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-library:jar is missing. @ line 88, column 22
[ERROR] ‘dependencies.dependency.version’ for org.scala-lang:scala-reflect:jar is missing. @ line 94, column 22
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
./buildmultiplescalaversions.sh: line 44: ./change-scala-versions.sh: No such file or directory

Keep an eye on this branch: It should work. Let me know if you have any questions:

The 1st problem can be solved by change
./buildnativeoperations.sh
(https://deeplearning4j.konduit.ai/getting-started/build-from-source#building-manually)
to
./buildnativeoperations.sh -platform linux-arm64

@liweigu just focus on compiling using maven:

mvn -Djavacpp.platform=linux-arm64 clean install -Dmaven.test.skip=true

is all you should need. Make sure you use my branch.

The error occurs in libnd4j/buildnativeoperations.sh at line 558:

eval $MAKE_COMMAND $MAKE_ARGUMENTS && cd …/…/…

the content of the command is

make -j 4

It hasn’t reached the place to comple java code using mvn, i think.

What version of GCC are you using?

gcc (Debian 8.3.0-6) 8.3.0
cmake version 3.16.5

This is a known bug. It was already addressed once, but looks like the same fix should be applied for all arm archs. I’ll apply fix later today.

Okey, i shall retry tomorrow or later.

I will post update here once it’s merged to KonduitAI repo. Thanks for highlighting this problem.

You are welcome :grinning:

@liweigu which repository you’ve cloned and tried to build?

The code is from

For the above (let’s call it Env-A), the source code is downloaded by “Download ZIP” from that page at 2020-03-16.

Here’s a new machine(called Env-B) on Huawei Cloud, it’s gcc version is

gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0

the source code is downloaded by git clone, and the compiling has finished nd4jcpu, the logs are:

[ 90%] Building CXX object blas/CMakeFiles/nd4jobj.dir/__/include/performance/benchmarking/impl/LightBenchmarkSuit.cpp.o
[ 99%] Built target nd4jobj
Scanning dependencies of target nd4jcpu
[100%] Linking CXX shared library libnd4jcpu.so
[100%] Built target nd4jcpu
buildmultiplescalaversions.sh: line 38: ./change-scala-versions.sh: No such file or directory
buildmultiplescalaversions.sh: line 43: ./change-scala-versions.sh: No such file or directory
./buildmultiplescalaversions.sh: line 44: ./change-scala-versions.sh: No such file or directory

I see. Please try to build from our dev repo: https://github.com/KonduitAI/deeplearning4j
This problem should be solved there by now.

OK, i try it. I will reply the result.

With repo: https://github.com/KonduitAI/deeplearning4j, the log (Env-B):

[ 6%] Building CXX object blas/CMakeFiles/nd4jobj.dir//include/ops/impl/gemm.cpp.o
[ 6%] Building CXX object blas/CMakeFiles/nd4jobj.dir/
/include/ops/impl/specials_sparse.cpp.o
[ 6%] Building CXX object blas/CMakeFiles/nd4jobj.dir//include/performance/benchmarking/impl/BenchmarkSuit.cpp.o
[ 6%] Building CXX object blas/CMakeFiles/nd4jobj.dir/
/include/performance/benchmarking/impl/FullBenchmarkSuit.cpp.o
[ 7%] Building CXX object blas/CMakeFiles/nd4jobj.dir/__/include/performance/benchmarking/impl/LightBenchmarkSuit.cpp.o
[ 99%] Built target nd4jobj
Scanning dependencies of target nd4jcpu
[100%] Linking CXX shared library libnd4jcpu.so
[100%] Built target nd4jcpu
buildmultiplescalaversions.sh: line 38: ./change-scala-versions.sh: No such file or directory
buildmultiplescalaversions.sh: line 43: ./change-scala-versions.sh: No such file or directory
./buildmultiplescalaversions.sh: line 44: ./change-scala-versions.sh: No such file or directory

So it builds fine on dev repo. I see. Thank you.

The compiled repository doesn’t include org/nd4j/nd4j-native-platform directory corresponding to the part of pom.xml:

	<dependency>
		<groupId>org.nd4j</groupId>
		<artifactId>nd4j-native-platform</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<classifier>linux-arm64</classifier>
	</dependency>

Did i miss something durning compiling?

Besides, when will you provide compiled arm support in 1.0.0-SNAPSHOT, so that i can just include them by maven?

I do ‘mvn install -Dmaven.test.skip=true’ in nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native-platform, then org/nd4j/nd4j-native-platform is compiled.

It should be there soon… @agibsonccc