Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ if(USE_OPENMP)
find_package(OpenMP REQUIRED)
# This should build on Windows, but there's some problem and I don't have a Windows box, so
# could a Windows user please fix?
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt AND SYSTEM_ARCHITECTURE STREQUAL "x86_64" AND NOT MSVC)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt
AND SYSTEM_ARCHITECTURE STREQUAL "x86_64"
AND NOT MSVC
AND NOT CMAKE_CROSSCOMPILING)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is CMAKE_CROSSCOMPILING enabled/governed? For android I noticed we are not in "cross compiling" mode or whatever that is supposed to be in cmake.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, saw it below.


# Intel/llvm OpenMP: https://github.com/llvm-mirror/openmp
set(OPENMP_STANDALONE_BUILD TRUE)
set(LIBOMP_ENABLE_SHARED TRUE)
Expand Down
15 changes: 9 additions & 6 deletions ci/docker/Dockerfile.build.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV8

WORKDIR /work
WORKDIR /work/deps

# Build OpenBLAS
RUN git clone --recursive -b v0.2.20 https://github.com/xianyi/OpenBLAS.git && \
cd OpenBLAS && \
make -j$(nproc) && \
PREFIX=${CROSS_ROOT} make install
COPY install/ubuntu_arm.sh /work/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to copy the scripts vs running them directly from the mount volume?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we have to copy them because the volumes are not mounted during build time of the container

RUN /work/ubuntu_arm.sh

COPY install/arm_openblas.sh /work/
RUN /work/arm_openblas.sh

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}

COPY runtime_functions.sh /work/
WORKDIR /work/mxnet
13 changes: 8 additions & 5 deletions ci/docker/Dockerfile.build.armv6
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ ENV TARGET ARMV6

WORKDIR /work/deps

# Build OpenBLAS
RUN git clone --recursive -b v0.2.20 https://github.com/xianyi/OpenBLAS.git && \
cd OpenBLAS && \
make -j$(nproc) && \
make PREFIX=$CROSS_ROOT install
COPY install/ubuntu_arm.sh /work/
RUN /work/ubuntu_arm.sh

COPY install/arm_openblas.sh /work/
RUN /work/arm_openblas.sh

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}

COPY runtime_functions.sh /work/
WORKDIR /work/mxnet
24 changes: 16 additions & 8 deletions ci/docker/Dockerfile.build.armv7
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.
#
# Dockerfile to build MXNet for Android ARMv7
# Dockerfile to build MXNet for ARMv7 (Android & RPi)

FROM ubuntu:16.04 as ccachebuilder

Expand All @@ -30,13 +30,21 @@ FROM dockcross/linux-armv7
# extract ccache binary into latest context
COPY --from=ccachebuilder /usr/local/bin/ccache /usr/local/bin/ccache

ENV ARCH armv71
ENV CC /usr/bin/arm-linux-gnueabihf-gcc
ENV CXX /usr/bin/arm-linux-gnueabihf-g++
ENV ARCH armv7l
ENV HOSTCC gcc
ENV TARGET ARMV7
ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran

RUN apt-get update && \
apt-get install -y libopenblas-dev:armhf && \
rm -rf /var/lib/apt/lists/*
WORKDIR /work/deps

COPY install/ubuntu_arm.sh /work/
RUN /work/ubuntu_arm.sh

COPY install/arm_openblas.sh /work/
RUN /work/arm_openblas.sh

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}

COPY runtime_functions.sh /work/
WORKDIR /work/build
WORKDIR /work/mxnet
15 changes: 9 additions & 6 deletions ci/docker/Dockerfile.build.jetson
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ ENV FC /usr/bin/${CROSS_TRIPLE}-gfortran
ENV HOSTCC gcc
ENV TARGET ARMV8

WORKDIR /work
WORKDIR /work/deps

# Build OpenBLAS
RUN git clone --recursive -b v0.2.20 https://github.com/xianyi/OpenBLAS.git && \
cd OpenBLAS && \
make -j$(nproc) && \
PREFIX=${CROSS_ROOT} make install
COPY install/ubuntu_arm.sh /work/
RUN /work/ubuntu_arm.sh

COPY install/arm_openblas.sh /work/
RUN /work/arm_openblas.sh

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}

ENV OpenBLAS_HOME=${CROSS_ROOT}
ENV OpenBLAS_DIR=${CROSS_ROOT}
Expand Down
30 changes: 30 additions & 0 deletions ci/docker/install/arm_openblas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env 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.

set -ex

git clone --recursive -b v0.2.20 https://github.com/xianyi/OpenBLAS.git

cd OpenBLAS
make -j$(nproc)
PREFIX=${CROSS_ROOT} make install

cd ..

rm -rf OpenBLAS
24 changes: 24 additions & 0 deletions ci/docker/install/ubuntu_arm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename file to match our filenaming style.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly the name you are suggesting in this case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this is fine :)


# 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.

set -ex

apt update
apt install -y \
unzip
88 changes: 58 additions & 30 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,52 @@ build_ccache_wrappers() {
export CXX=`pwd`/cxx
}

# Build commands: Every platform in docker/Dockerfile.build.<platform> should have a corresponding
# function here with the same suffix:
build_wheel() {

build_jetson() {
set -ex
pushd .

build_ccache_wrappers
PYTHON_DIR=${1:-/work/mxnet/python}
BUILD_DIR=${2:-/work/build}

cp -f make/crosscompile.jetson.mk ./config.mk
# build

make -j$(nproc)
export MXNET_LIBRARY_PATH=${BUILD_DIR}/libmxnet.so

export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
cd /work/mxnet/python
cd ${PYTHON_DIR}
python setup.py bdist_wheel --universal

# repackage

# Fix pathing issues in the wheel. We need to move libmxnet.so from the data folder to the
# mxnet folder, then repackage the wheel.
WHEEL=`readlink -f dist/*.whl`
TMPDIR=`mktemp -d`
unzip -d $TMPDIR $WHEEL
rm $WHEEL
cd $TMPDIR
unzip -d ${TMPDIR} ${WHEEL}
rm ${WHEEL}
cd ${TMPDIR}
mv *.data/data/mxnet/libmxnet.so mxnet
zip -r $WHEEL .
cp $WHEEL /work/build
rm -rf $TMPDIR
zip -r ${WHEEL} .
cp ${WHEEL} ${BUILD_DIR}
rm -rf ${TMPDIR}

popd
}

# Build commands: Every platform in docker/Dockerfile.build.<platform> should have a corresponding
# function here with the same suffix:

build_jetson() {
set -ex
pushd .

build_ccache_wrappers

cp -f make/crosscompile.jetson.mk ./config.mk
make -j$(nproc)

build_wheel /work/mxnet/python /work/mxnet/lib

popd
}

Expand All @@ -107,7 +125,7 @@ build_armv6() {
# We do not need OpenMP, since most armv6 systems have only 1 core

cmake \
-DCMAKE_TOOLCHAIN_FILE=$CROSS_ROOT/Toolchain.cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DUSE_CUDA=OFF \
Expand All @@ -120,33 +138,43 @@ build_armv6() {
-DBUILD_CPP_EXAMPLES=OFF \
-Dmxnet_LINKER_LIBS=-lgfortran \
-G Ninja /work/mxnet

ninja
export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
cd /work/mxnet/python
python setup.py bdist_wheel --universal
cp dist/*.whl /work/build
build_wheel

popd
}

build_armv7() {
set -ex
pushd .

cd /work/build

# Lapack functionality will be included and statically linked to openblas.
# But USE_LAPACK needs to be set to OFF, otherwise the main CMakeLists.txt
# file tries to add -llapack. Lapack functionality though, requires -lgfortran
# to be linked additionally.

cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_CROSSCOMPILING=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DUSE_CUDA=OFF\
-DUSE_OPENCV=OFF\
-DUSE_OPENMP=OFF\
-DUSE_SIGNAL_HANDLER=ON\
-DCMAKE_BUILD_TYPE=RelWithDebInfo\
-DUSE_MKL_IF_AVAILABLE=OFF\
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DUSE_CUDA=OFF \
-DUSE_OPENCV=OFF \
-DUSE_OPENMP=ON \
-DUSE_SIGNAL_HANDLER=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_LAPACK=OFF \
-DBUILD_CPP_EXAMPLES=OFF \
-Dmxnet_LINKER_LIBS=-lgfortran \
-G Ninja /work/mxnet

ninja
export MXNET_LIBRARY_PATH=`pwd`/libmxnet.so
cd /work/mxnet/python
python setup.py bdist_wheel --universal
cp dist/*.whl /work/build
build_wheel

popd
}

Expand Down