Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit fe90008

Browse files
nickguletskiileezu
andauthored
[v1.x] Backport edge pipeline (#18375)
* Update edge toolchain * Support platforms without rand_r * Fix the URL to the IUS repository * compiler warnings * Use a pre-c++17 way of distinguishing between device types * Greatly simplify qemu setup * Request the C++ standard library and extensions * Upgrade dmlc-core to resolve build errors * Remove leftovers from C++17 dev type check * Fix CPU-only RRNOp Forward * Change the ARM8 build to work like the ARM7 build * Revert "Fix CPU-only RRNOp Forward" This reverts commit 0a921a4. * Hack around the lack of constexpr if * Adjust the list of files to be packed in ARM jobs Co-authored-by: Leonard Lausen <[email protected]>
1 parent 38ec873 commit fe90008

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+676
-1800
lines changed

3rdparty/mshadow/mshadow/logging.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ class LogMessageFatal {
223223
~LogMessageFatal() MSHADOW_THROW_EXCEPTION {
224224
// throwing out of destructor is evil
225225
// hopefully we can do it here
226+
#pragma GCC diagnostic push
227+
#if __GNUC__ >= 7
228+
#pragma GCC diagnostic ignored "-Wterminate"
229+
#endif
226230
throw Error(log_stream_.str());
231+
#pragma GCC diagnostic pop
227232
}
228233

229234
private:

3rdparty/mshadow/mshadow/packet-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ inline void* AlignedMallocPitch(size_t *out_pitch,
9393
if (res == NULL) {
9494
LOG(FATAL) << "AlignedMallocPitch failed";
9595
}
96+
#if __GNUC__ >= 6
97+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
98+
#endif
9699
return res;
100+
#pragma GCC diagnostic pop
97101
}
98102

99103
/*!

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if(CMAKE_CROSSCOMPILING)
77
endif()
88

99
project(mxnet C CXX)
10+
set(CMAKE_CXX_STANDARD 11)
11+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
set(CMAKE_CXX_EXTENSIONS ON)
1013

1114
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)
1215
# Load config.cmake only if mxnet is not compiled as a dependency of another project
@@ -202,7 +205,7 @@ endif(MSVC)
202205

203206
if(NOT mxnet_LINKER_LIBS)
204207
set(mxnet_LINKER_LIBS "")
205-
endif(NOT mxnet_LINKER_LIBS)
208+
endif()
206209

207210
if(USE_GPROF)
208211
message(STATUS "Using GPROF")

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ CFLAGS += -DDMLC_LOG_STACK_TRACE_SIZE=0
9999
CFLAGS += -DDMLC_LOG_FATAL_THROW=1
100100

101101
ifeq ($(DEV), 1)
102-
CFLAGS += -g -Werror
102+
# Excluded from Werror:
103+
# 1) variables used in '#pragma omp parallel' are considered unused
104+
CFLAGS += -g -Werror -Wno-error=unused-variable -Wno-error=maybe-uninitialized -Wno-error=unused-function
103105
NVCCFLAGS += -Werror cross-execution-space-call
104106
endif
105107

ci/README.md

Lines changed: 21 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -111,90 +111,37 @@ significantly. You can set this directory explicitly by setting CCACHE_DIR envir
111111
variable. All ccache instances are currently set to be 10 Gigabytes max in size.
112112

113113

114-
## Testing with QEMU
115-
To run the unit tests under qemu:
116-
```
117-
./build.py -p armv7 && ./build.py -p test.arm_qemu ./runtime_functions.py run_ut_py3_qemu
118-
```
119-
120-
To get a shell on the container and debug issues with the emulator itself, we build the container
121-
and then execute it interactively. We can afterwards use port 2222 on the host to connect with SSH.
122-
123-
124-
```
125-
ci/build.py -p test.arm_qemu -b && docker run -p2222:2222 -ti mxnetci/build.test.arm_qemu
126-
```
114+
## Testing with ARM / Edge devices with QEMU
127115

128-
Then from another terminal:
116+
We build on [QEMU](https://www.qemu.org/) and Linux [Kernel Support for
117+
miscellaneous Binary
118+
Formats](https://www.kernel.org/doc/html/v5.6/admin-guide/binfmt-misc.html) for
119+
testing MXNet on edge devices. Test can be invoked with the same syntax as for
120+
non-virtualized platforms:
129121

130122
```
131-
ssh -o StrictHostKeyChecking=no -p 2222 qemu@localhost
123+
./build.py -p armv7
124+
./build.py -p test.armv7 /work/runtime_functions.sh unittest_ubuntu_python3_armv7
132125
```
133126

134-
There are two pre-configured users: `root` and `qemu` both without passwords.
135-
136-
137-
### Example of reproducing a test result with QEMU on ARM
138-
139-
140-
You might want to enable a debug build first:
141-
142-
```
143-
$ git diff
144-
diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh
145-
index 39631f9..666ceea 100755
146-
--- a/ci/docker/runtime_functions.sh
147-
+++ b/ci/docker/runtime_functions.sh
148-
@@ -172,6 +172,7 @@ build_armv7() {
149-
-DUSE_LAPACK=OFF \
150-
-DBUILD_CPP_EXAMPLES=OFF \
151-
-Dmxnet_LINKER_LIBS=-lgfortran \
152-
+ -DCMAKE_BUILD_TYPE=Debug \
153-
-G Ninja /work/mxnet
154-
155-
ninja -v
127+
For the test step to succeed, you must run Linux kernel 4.8 or later and have qemu installed.
156128

129+
On Debian and Ubuntu systems, run the following command to install the dependencies:
157130
```
131+
sudo apt install binfmt-support qemu-user-static
158132
159-
Then we build the project for armv7, the test container and start QEMU inside docker:
160-
161-
```
162-
ci/build.py -p armv7
163-
ci/build.py -p test.arm_qemu -b && docker run -p2222:2222 -ti mxnetci/build.test.arm_qemu
133+
# Use qemu-binfmt-conf.sh to register all binary types with the kernel
134+
wget https://raw.githubusercontent.com/qemu/qemu/stable-4.1/scripts/qemu-binfmt-conf.sh
135+
chmod +x qemu-binfmt-conf.sh
136+
sudo ./qemu-binfmt-conf.sh --persistent yes --qemu-suffix "-static" --qemu-path "/usr/bin" --systemd ALL
164137
```
165138

166-
167-
168-
At this point we copy artifacts and sources to the VM, in another terminal (host) do the following:
139+
If you run into segmentation faults at the beginning of the emulated tests, you
140+
probably have a ancient version of Qemu on your system (or found a bug in
141+
upstream Qemu). In that situation, you can rely on the
142+
`multiarch/qemu-user-static` Docker project to register a set of up-to-date Qemu
143+
binaries from their Docker image with your kernel:
169144

170145
```
171-
# Copy mxnet sources to the VM
172-
rsync --delete -e 'ssh -p2222' --exclude='.git/' -zvaP ./ qemu@localhost:mxnet
173-
174-
175-
# Ssh into the vm
176-
ssh -p2222 qemu@localhost
177-
178-
cd mxnet
179-
180-
# Execute a single failing C++ test
181-
build/tests/mxnet_unit_tests --gtest_filter="ACTIVATION_PERF.ExecuteBidirectional"
182-
183-
# To install MXNet:
184-
sudo pip3 install --upgrade --force-reinstall build/mxnet-1.3.1-py2.py3-none-any.whl
185-
186-
# Execute a single python test:
187-
188-
nosetests-3.4 -v -s tests/python/unittest/test_ndarray.py
189-
190-
191-
# Debug with cgdb
192-
sudo apt install -y libstdc++6-6-dbg
193-
cgdb build/tests/mxnet_unit_tests
194-
195-
(gdb) !pwd
196-
/home/qemu/mxnet
197-
(gdb) set substitute-path /work /home/qemu
198-
(gdb) set substitute-path /build/gcc-6-6mK9AW/gcc-6-6.3.0/build/arm-linux-gnueabihf/libstdc++-v3/include/ /usr/include/c++/6/
199-
(gdb) r --gtest_filter="ACTIVATION_PERF.ExecuteBidirectional"
146+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
200147
```

ci/build.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def get_docker_binary(use_nvidia_docker: bool) -> str:
7070
return "nvidia-docker" if use_nvidia_docker else "docker"
7171

7272

73-
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int, no_cache: bool) -> str:
73+
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int, no_cache: bool,
74+
cache_intermediate: bool) -> str:
7475
"""
7576
Build a container for the given platform
7677
:param platform: Platform
@@ -104,6 +105,8 @@ def build_docker(platform: str, docker_binary: str, registry: str, num_retries:
104105
"--build-arg", "GROUP_ID={}".format(os.getgid())]
105106
if no_cache:
106107
cmd.append("--no-cache")
108+
if cache_intermediate:
109+
cmd.append("--rm=false")
107110
elif registry:
108111
cmd.extend(["--cache-from", tag])
109112
cmd.extend(["-t", tag, get_dockerfiles_path()])
@@ -330,6 +333,9 @@ def main() -> int:
330333
parser.add_argument("--no-cache", action="store_true",
331334
help="passes --no-cache to docker build")
332335

336+
parser.add_argument("--cache-intermediate", action="store_true",
337+
help="passes --rm=false to docker build")
338+
333339
parser.add_argument("-e", "--environment", nargs="*", default=[],
334340
help="Environment variables for the docker container. "
335341
"Specify with a list containing either names or name=value")
@@ -361,7 +367,8 @@ def main() -> int:
361367
load_docker_cache(tag=tag, docker_registry=args.docker_registry)
362368
if not args.run_only:
363369
build_docker(platform=platform, docker_binary=docker_binary, registry=args.docker_registry,
364-
num_retries=args.docker_build_retries, no_cache=args.no_cache)
370+
num_retries=args.docker_build_retries, no_cache=args.no_cache,
371+
cache_intermediate=args.cache_intermediate)
365372
else:
366373
logging.info("Skipping docker build step.")
367374

ci/dev_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def provision_virtualenv(venv_path=DEFAULT_PYENV):
167167
('[Docker] Python3 ARMv7 unittests (QEMU)',
168168
[
169169
"ci/build.py -p armv7",
170-
"ci/build.py -p test.arm_qemu ./runtime_functions.py run_ut_py3_qemu"
170+
"ci/build.py -p test.armv7 /work/runtime_functions.sh unittest_ubuntu_python3_armv7"
171171
]),
172172
('Clean (RESET HARD) repository (Warning! erases local changes / DATA LOSS)',
173173
Confirm("ci/docker/runtime_functions.sh clean_repo"))

ci/docker/Dockerfile.build.android_armv7

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,46 @@
1818
#
1919
# Dockerfile to build MXNet for Android ARMv7
2020

21-
FROM dockcross/base
22-
MAINTAINER Pedro Larroy "[email protected]"
23-
24-
# The cross-compiling emulator
25-
RUN apt-get update && apt-get install -y \
26-
unzip
27-
28-
ENV CROSS_TRIPLE=arm-linux-androideabi
29-
ENV CROSS_ROOT=/usr/${CROSS_TRIPLE}
30-
ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
31-
AR=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ar \
32-
CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \
33-
CPP=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-cpp \
34-
CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ \
35-
LD=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ld
36-
37-
ENV ANDROID_NDK_REVISION 17b
38-
ENV ANDROID_NDK_API 27
39-
ENV ANDROID_NDK_ARCH arm
40-
WORKDIR /work/deps
41-
COPY install/android_ndk.sh /work/deps
42-
RUN /work/deps/android_ndk.sh
43-
44-
ENV DEFAULT_DOCKCROSS_IMAGE dockcross/android-arm
45-
46-
# Build-time metadata as defined at http://label-schema.org
47-
ARG BUILD_DATE
48-
ARG IMAGE
49-
ARG VCS_REF
50-
ARG VCS_URL
51-
LABEL org.label-schema.build-date=$BUILD_DATE \
52-
org.label-schema.name=$IMAGE \
53-
org.label-schema.vcs-ref=$VCS_REF \
54-
org.label-schema.vcs-url=$VCS_URL \
55-
org.label-schema.schema-version="1.0"
56-
57-
58-
ENV CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang
59-
ENV CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-clang++
60-
61-
WORKDIR /work/deps
62-
63-
COPY install/deb_ubuntu_ccache.sh /work/
64-
RUN /work/deb_ubuntu_ccache.sh
65-
WORKDIR /work
66-
COPY install/ubuntu_arm.sh /work/
67-
RUN /work/ubuntu_arm.sh
68-
69-
COPY install/arm_openblas.sh /work/
70-
COPY install/android_armv7_openblas.sh /work/deps
71-
RUN /work/deps/android_armv7_openblas.sh
72-
73-
ENV OpenBLAS_HOME=${CROSS_ROOT}
74-
ENV OpenBLAS_DIR=${CROSS_ROOT}
75-
76-
WORKDIR /work
21+
FROM ubuntu:20.04
22+
23+
ENV ARCH=armv7l \
24+
HOSTCC=gcc \
25+
HOSTCXX=g++ \
26+
TARGET=ARMV7
27+
28+
WORKDIR /usr/local
29+
30+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
31+
build-essential \
32+
ninja-build \
33+
cmake \
34+
ccache \
35+
git \
36+
curl \
37+
unzip \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
RUN curl -o android-ndk-r19-linux-x86_64.zip -L https://dl.google.com/android/repository/android-ndk-r19-linux-x86_64.zip && \
41+
unzip android-ndk-r19-linux-x86_64.zip && \
42+
rm android-ndk-r19-linux-x86_64.zip
43+
ENV CMAKE_TOOLCHAIN_FILE=/usr/local/android-ndk-r19/build/cmake/android.toolchain.cmake
44+
45+
RUN git clone --recursive -b v0.3.9 https://github.com/xianyi/OpenBLAS.git && \
46+
mkdir /usr/local/openblas-android && \
47+
cd /usr/local/OpenBLAS && \
48+
export TOOLCHAIN=/usr/local/android-ndk-r19/toolchains/llvm/prebuilt/linux-x86_64 && \
49+
make NOFORTRAN=1 ARM_SOFTFP_ABI=1 NO_SHARED=1 \
50+
LDFLAGS="-L/usr/local/android-ndk-r19/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x -lm" \
51+
CC=$TOOLCHAIN/bin/armv7a-linux-androideabi16-clang AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar && \
52+
make PREFIX=/usr/local/openblas-android NO_SHARED=1 install && \
53+
cd /usr/local && \
54+
rm -rf OpenBLAS
55+
ENV OpenBLAS_HOME=/usr/local/openblas-android
7756

7857
ARG USER_ID=0
7958
ARG GROUP_ID=0
8059
COPY install/ubuntu_adduser.sh /work/
8160
RUN /work/ubuntu_adduser.sh
8261

8362
COPY runtime_functions.sh /work/
84-
WORKDIR /work/mxnet
85-
63+
WORKDIR /work/build

0 commit comments

Comments
 (0)