You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/07/02 17:35:24 UTC

[GitHub] marcoabreu closed pull request #11382: [MXNET-57] Android ARMv7 support

marcoabreu closed pull request #11382: [MXNET-57] Android ARMv7 support
URL: https://github.com/apache/incubator-mxnet/pull/11382
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/Jenkinsfile b/Jenkinsfile
index ef84933fdcb..1e2a9082d6c 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -501,7 +501,18 @@ try {
           }
         }
       }
+    },
+    'Android / ARMv7':{
+      node('mxnetlinux-cpu') {
+        ws('workspace/androidv7') {
+          timeout(time: max_time, unit: 'MINUTES') {
+            init_git()
+            docker_run('android_armv7', 'build_android_armv7', false)
+          }
+        }
+      }
     }
+
   } // End of stage('Build')
 
   stage('Tests') {
diff --git a/ci/build.py b/ci/build.py
index 680f4574fd8..69d3b1059d1 100755
--- a/ci/build.py
+++ b/ci/build.py
@@ -42,6 +42,10 @@
 
 CCACHE_MAXSIZE = '500G'
 
+def under_ci() -> bool:
+    """:return: True if we run in Jenkins."""
+    return 'JOB_NAME' in os.environ
+
 def get_platforms(path: Optional[str] = "docker"):
     """Get a list of architectures given our dockerfiles"""
     dockerfiles = glob.glob(os.path.join(path, "Dockerfile.build.*"))
@@ -268,7 +272,7 @@ def script_name() -> str:
 
     args = parser.parse_args()
     def use_cache():
-        return args.cache or 'JOB_NAME' in os.environ # we are in Jenkins
+        return args.cache or under_ci()
 
     command = list(chain(*args.command))
     docker_binary = get_docker_binary(args.nvidiadocker)
diff --git a/ci/docker/Dockerfile.build.android_arm64 b/ci/docker/Dockerfile.build.android_arm64
index 427cc0368db..d992441eea0 100755
--- a/ci/docker/Dockerfile.build.android_arm64
+++ b/ci/docker/Dockerfile.build.android_arm64
@@ -55,14 +55,22 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
       org.label-schema.schema-version="1.0"
 
 ENV ARCH aarch64
-ENV ANDROID_NDK_REVISION 15c
+ENV ANDROID_NDK_REVISION 17b
+ENV ANDROID_NDK_API 27
+ENV ANDROID_NDK_ARCH arm64
+WORKDIR /work/deps
+COPY install/android_ndk.sh /work/deps
+RUN /work/deps/android_ndk.sh
+
+
+WORKDIR /work/deps
+COPY install/android_ndk.sh /work/
+RUN /work/android_ndk.sh
 
 ENV CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang
 ENV CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang++
 
 # Build ARM dependencies.
-COPY install/android_arm64_ndk.sh /work/
-RUN /work/android_arm64_ndk.sh
 COPY install/android_arm64_openblas.sh /work/
 RUN /work/android_arm64_openblas.sh
 ENV CPLUS_INCLUDE_PATH /work/deps/OpenBLAS
diff --git a/ci/docker/Dockerfile.build.android_armv7 b/ci/docker/Dockerfile.build.android_armv7
index 859ea02fb36..f5a8d09b53d 100755
--- a/ci/docker/Dockerfile.build.android_armv7
+++ b/ci/docker/Dockerfile.build.android_armv7
@@ -23,8 +23,6 @@ MAINTAINER Pedro Larroy "pllarroy@amazon.com"
 
 # The cross-compiling emulator
 RUN apt-get update && apt-get install -y \
-  qemu-user \
-  qemu-user-static \
   unzip
 
 ENV CROSS_TRIPLE=arm-linux-androideabi
@@ -36,22 +34,12 @@ ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
     CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ \
     LD=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ld
 
-ENV ANDROID_NDK_REVISION 15c
-RUN mkdir -p /build && \
-    cd /build && \
-    curl -O https://dl.google.com/android/repository/android-ndk-r${ANDROID_NDK_REVISION}-linux-x86_64.zip && \
-    unzip ./android-ndk-r${ANDROID_NDK_REVISION}-linux-x86_64.zip && \
-    cd android-ndk-r${ANDROID_NDK_REVISION} && \
-    ./build/tools/make_standalone_toolchain.py \
-      --stl=libc++ \
-      --arch arm \
-      --api 16 \
-      --install-dir=${CROSS_ROOT} && \
-    cd / && \
-    rm -rf /build && \
-    find ${CROSS_ROOT} -exec chmod a+r '{}' \; && \
-    find ${CROSS_ROOT} -executable -exec chmod a+x '{}' \;
-
+ENV ANDROID_NDK_REVISION 17b
+ENV ANDROID_NDK_API 27
+ENV ANDROID_NDK_ARCH arm
+WORKDIR /work/deps
+COPY install/android_ndk.sh /work/deps
+RUN /work/deps/android_ndk.sh
 
 ENV DEFAULT_DOCKCROSS_IMAGE dockcross/android-arm
 
@@ -66,30 +54,27 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
       org.label-schema.vcs-url=$VCS_URL \
       org.label-schema.schema-version="1.0"
 
-ENV CC /usr/arm-linux-androideabi/bin/arm-linux-androideabi-gcc
-ENV CXX /usr/arm-linux-androideabi/bin/arm-linux-androideabi-g++
-
-# Build OpenBLAS
-# https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android
-RUN git clone https://github.com/xianyi/OpenBLAS.git && \
-    cd OpenBLAS && \
-    make -j$(nproc) TARGET=ARMV7 ARM_SOFTFP_ABI=1 HOSTCC=gcc NOFORTRAN=1 libs
 
-ENV OPENBLAS_ROOT /work/OpenBLAS
-ENV LIBRARY_PATH /work/OpenBLAS/lib/:/work/OpenBLAS/:$LIBRARY_PATH
-ENV CPLUS_INCLUDE_PATH /work/OpenBLAS/include/:/work/OpenBLAS/:$CPLUS_INCLUDE_PATH
+ENV CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang
+ENV CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang++
 
 WORKDIR /work/deps
 
 COPY install/deb_ubuntu_ccache.sh /work/
 RUN /work/deb_ubuntu_ccache.sh
-
 WORKDIR /work
+COPY install/ubuntu_arm.sh /work/
+RUN /work/ubuntu_arm.sh
 
-ENV CC /usr/arm-linux-androideabi/bin/arm-linux-androideabi-clang
-ENV CXX /usr/arm-linux-androideabi/bin/arm-linux-androideabi-clang++
-ENV BUILD_OPTS "USE_BLAS=openblas USE_SSE=0 DMLC_LOG_STACK_TRACE=0 USE_OPENCV=0 USE_LAPACK=0"
+COPY install/arm_openblas.sh /work/
+COPY install/android_armv7_openblas.sh /work/deps
+RUN /work/deps/android_armv7_openblas.sh
 
-WORKDIR /work/mxnet
+ENV OpenBLAS_HOME=${CROSS_ROOT}
+ENV OpenBLAS_DIR=${CROSS_ROOT}
+
+WORKDIR /work
 
 COPY runtime_functions.sh /work/
+WORKDIR /work/mxnet
+
diff --git a/ci/docker/install/android_armv7_openblas.sh b/ci/docker/install/android_armv7_openblas.sh
new file mode 100755
index 00000000000..ff7eadba0cb
--- /dev/null
+++ b/ci/docker/install/android_armv7_openblas.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# build and install are separated so changes to build don't invalidate
+# the whole docker cache for the image
+
+set -ex
+pushd .
+git clone https://github.com/xianyi/OpenBLAS.git
+cd OpenBLAS
+make TARGET=ARMV7 HOSTCC=gcc NOFORTRAN=1 ARM_SOFTFP_ABI=1 -j$(nproc) libs
+#make PREFIX=${CROSS_ROOT} TARGET=ARMV7 HOSTCC=gcc NOFORTRAN=1 ARM_SOFTFP_ABI=1 install
+cp *.h ${CROSS_ROOT}/include
+cp libopenblas*.a ${CROSS_ROOT}/lib
+popd
diff --git a/ci/docker/install/android_arm64_ndk.sh b/ci/docker/install/android_ndk.sh
similarity index 89%
rename from ci/docker/install/android_arm64_ndk.sh
rename to ci/docker/install/android_ndk.sh
index 04023fbdebe..fb5640eefbf 100755
--- a/ci/docker/install/android_arm64_ndk.sh
+++ b/ci/docker/install/android_ndk.sh
@@ -29,8 +29,10 @@ unzip ./android-ndk-r${ANDROID_NDK_REVISION}-linux-x86_64.zip && \
 cd android-ndk-r${ANDROID_NDK_REVISION} && \
 ./build/tools/make_standalone_toolchain.py \
     --stl=libc++ \
-    --arch arm64 \
-    --api 21 \
+    --arch ${ANDROID_NDK_ARCH}\
+    --api ${ANDROID_NDK_API}\
     --install-dir=${CROSS_ROOT} && \
 
+find ${CROSS_ROOT} -exec chmod a+r '{}' \; && \
+find ${CROSS_ROOT} -executable -exec chmod a+x '{}' \;
 popd
diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh
index 71229814399..216e886180c 100755
--- a/ci/docker/runtime_functions.sh
+++ b/ci/docker/runtime_functions.sh
@@ -208,7 +208,6 @@ build_amzn_linux_cpu() {
         -G Ninja /work/mxnet
     ninja -v
     report_ccache_usage
-    export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
 }
 
 build_arm64() {
@@ -225,16 +224,17 @@ build_arm64() {
         -G Ninja /work/mxnet
     ninja -v
     report_ccache_usage
-    export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
-    cd /work/mxnet/python
-    python setup.py bdist_wheel --universal
-    cp dist/*.whl /work/build
+    build_wheel
 }
 
 build_android_armv7() {
     set -ex
     cd /work/build
+#        -DCMAKE_SYSTEM_NAME=Android\
+#        -DCMAKE_ANDROID_NDK=${CROSS_ROOT} \
+#        -DCMAKE_SYSTEM_VERSION=21\
     cmake \
+        -DANDROID=ON\
         -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
         -DCMAKE_C_COMPILER_LAUNCHER=ccache \
         -DUSE_CUDA=OFF\
@@ -249,10 +249,6 @@ build_android_armv7() {
         -G Ninja /work/mxnet
     ninja -v
     report_ccache_usage
-    export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
-    cd /work/mxnet/python
-    python setup.py bdist_wheel --universal
-    cp dist/*.whl /work/build
 }
 
 build_android_arm64() {
@@ -263,8 +259,7 @@ build_android_arm64() {
 # build with CMake in Android.
 #        -DCMAKE_ANDROID_NDK=${CROSS_ROOT} \
 #        -DCMAKE_SYSTEM_VERSION=${ANDROID_NDK_REVISION} \
-#        -DCMAKE_SYSTEM_NAME=Android \
-#
+#        -DCMAKE_SYSTEM_VERSION=21\
     cmake\
         -DANDROID=ON \
         -DUSE_CUDA=OFF\


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services