From c4d9f6c2e02a51b3e43eb726f1d2fe113b47ab60 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Mon, 8 Jun 2020 20:22:45 +0000 Subject: [PATCH 1/9] Update ci/docker/install/requirements --- ci/docker/Dockerfile.build.centos7 | 14 +++----------- ci/docker/install/requirements | 10 +++++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/ci/docker/Dockerfile.build.centos7 b/ci/docker/Dockerfile.build.centos7 index a0b5b127e7ea..8f6587ea17c1 100644 --- a/ci/docker/Dockerfile.build.centos7 +++ b/ci/docker/Dockerfile.build.centos7 @@ -120,17 +120,9 @@ RUN export SHORT_CUDA_VERSION=${CUDA_VERSION%.*} && \ fi # Python dependencies -RUN pip3 install --no-cache-dir --upgrade pip && \ - pip3 install --no-cache-dir pylint cython numpy requests h5py scipy==1.2.3 wheel \ - pytest==5.3.5 \ - pytest-env==0.6.2 \ - pytest-cov==2.8.1 \ - pytest-xdist==1.31.0 \ - pytest-timeout==1.3.4 \ - mock==2.0.0 \ - onnx==1.5.0 \ - protobuf==3.5.2 \ - tabulate==0.7.5 +COPY install/requirements /work/ +RUN python -m pip install --no-cache-dir --upgrade pip && \ + python -m pip install --no-cache-dir -r /work/requirements # Fix the en_DK.UTF-8 locale to test locale invariance RUN localedef -i en_DK -f UTF-8 en_DK.UTF-8 diff --git a/ci/docker/install/requirements b/ci/docker/install/requirements index ce06681d96af..e5fdc9bdcc1a 100644 --- a/ci/docker/install/requirements +++ b/ci/docker/install/requirements @@ -35,14 +35,14 @@ Cython==0.29.7 cpplint==1.3.0 pylint==2.3.1 # pylint and astroid need to be aligned astroid==2.3.3 # pylint and astroid need to be aligned -pytest==5.3.5 +pytest==5.4.2 pytest-env==0.6.2 -pytest-cov==2.8.1 -pytest-xdist==1.31.0 +pytest-cov==2.9.0 +pytest-xdist==1.32.0 pytest-timeout==1.3.4 flaky==3.6.1 -setuptools -mock==2.0.0 +setuptools==47.1.1 +wheel==0.34.2 # TVM dependencies decorator==4.4.0 From 7473a6c2369badf764b8ccefca89dc3d4f20f352 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Mon, 8 Jun 2020 20:22:52 +0000 Subject: [PATCH 2/9] Switch to flang to avoid libgfortran.so GPL runtime dependency Flang fortran compiler as replacement for gfortran due to the resulting runtime dependency on libgfortran.so which is GPL-licensed and thus https://www.apache.org/legal/resolved.html#category-x for distribution. We need a Fortran compiler to compile the OpenBLAS Lapack implementation. --- cd/mxnet_lib/static/Jenkins_pipeline.groovy | 4 +-- ci/build.py | 5 +++- ci/docker/Dockerfile.build.centos7 | 18 ++++++++---- ci/docker/runtime_functions.sh | 28 +++++++++---------- cmake/ChooseBlas.cmake | 3 ++ make/staticbuild/linux_cpu.mk | 2 +- make/staticbuild/linux_cu100.mk | 4 +-- make/staticbuild/linux_cu101.mk | 4 +-- make/staticbuild/linux_cu102.mk | 4 +-- make/staticbuild/linux_cu92.mk | 4 +-- make/staticbuild/linux_native.mk | 2 +- .../assembly/src/main/assembly/assembly.xml | 3 +- .../mxnet/util/NativeLibraryLoader.scala | 3 +- .../dependencies/LICENSE.binary.dependencies | 12 +++++++- tools/dependencies/README.md | 6 ---- tools/dependencies/libpng.sh | 2 +- tools/dependencies/libturbojpeg.sh | 3 +- tools/dependencies/openblas.sh | 24 ++++------------ tools/dependencies/opencv.sh | 2 +- tools/dependencies/openssl.sh | 3 +- tools/dependencies/protobuf.sh | 7 +++-- tools/pip/setup.py | 13 ++------- tools/staticbuild/build.sh | 6 ++-- tools/staticbuild/build_lib.sh | 3 +- tools/staticbuild/build_lib_cmake.sh | 4 +-- 25 files changed, 82 insertions(+), 87 deletions(-) diff --git a/cd/mxnet_lib/static/Jenkins_pipeline.groovy b/cd/mxnet_lib/static/Jenkins_pipeline.groovy index 19f2a38d7513..8da0512d9a53 100644 --- a/cd/mxnet_lib/static/Jenkins_pipeline.groovy +++ b/cd/mxnet_lib/static/Jenkins_pipeline.groovy @@ -32,8 +32,8 @@ libmxnet = 'lib/libmxnet.so' licenses = 'licenses/*' // libmxnet dependencies -mx_native_deps = 'lib/libgfortran.so.4, lib/libquadmath.so.0, lib/libopenblas.so.0' -mx_deps = 'lib/libgfortran.so.4, lib/libquadmath.so.0, lib/libopenblas.so.0, include/mkldnn/dnnl_version.h, include/mkldnn/dnnl_config.h' +mx_native_deps = 'lib/libomp.so' +mx_deps = 'lib/libomp.so, include/mkldnn/dnnl_version.h, include/mkldnn/dnnl_config.h' // library type // either static or dynamic - depending on how it links to its dependencies diff --git a/ci/build.py b/ci/build.py index 1a8537bcfafe..fb9bb312d5f7 100755 --- a/ci/build.py +++ b/ci/build.py @@ -357,6 +357,9 @@ def main() -> int: default='mxnetci', type=str) + parser.add_argument("--no-pull", action="store_true", + help="Don't pull from dockerhub registry to initialize cache.") + parser.add_argument("-r", "--docker-build-retries", help="Number of times to retry building the docker image. Default is 1", default=1, @@ -394,7 +397,7 @@ def main() -> int: elif args.platform: platform = args.platform tag = get_docker_tag(platform=platform, registry=args.docker_registry) - if args.docker_registry: + if args.docker_registry and not args.no_pull: load_docker_cache(tag=tag, docker_registry=args.docker_registry) if not args.run_only: build_docker(platform=platform, registry=args.docker_registry, num_retries=args.docker_build_retries, diff --git a/ci/docker/Dockerfile.build.centos7 b/ci/docker/Dockerfile.build.centos7 index 8f6587ea17c1..325878d744a9 100644 --- a/ci/docker/Dockerfile.build.centos7 +++ b/ci/docker/Dockerfile.build.centos7 @@ -52,7 +52,8 @@ RUN yum -y check-update || true && \ protobuf-compiler \ protobuf-devel \ # CentOS Software Collections https://www.softwarecollections.org - devtoolset-7 \ + llvm-toolset-7.0 \ + llvm-toolset-7.0-libomp-devel \ rh-python36 \ rh-maven35 \ # Libraries @@ -67,13 +68,11 @@ RUN yum -y check-update || true && \ gperf \ libb2-devel \ libzstd-devel && \ - yum clean all && \ - # Centos 7 only provides ninja-build - ln -s /usr/bin/ninja-build /usr/bin/ninja + yum clean all # Make GCC7, Python 3.5 and Maven 3.3 Software Collections available by default # during build and runtime of this container -SHELL [ "/usr/bin/scl", "enable", "devtoolset-7", "rh-python36", "rh-maven35" ] +SHELL [ "/usr/bin/scl", "enable", "llvm-toolset-7.0", "rh-python36", "rh-maven35" ] # Install minimum required cmake version RUN cd /usr/local/src && \ @@ -119,6 +118,15 @@ RUN export SHORT_CUDA_VERSION=${CUDA_VERSION%.*} && \ yum clean all; \ fi +# Flang fortran compiler as replacement for gfortran due to the resulting +# runtime dependency on libgfortran.so which is GPL-licensed and thus +# https://www.apache.org/legal/resolved.html#category-x for distribution. +# We need a Fortran compiler to compile the OpenBLAS Lapack implementation. +RUN cd /usr/local/ && mkdir flang && cd flang && \ + wget -nv https://github.com/flang-compiler/flang/releases/download/flang_20190329/flang-20190329-x86-70.tgz && \ + tar xf flang-20190329-x86-70.tgz && \ + rm flang-20190329-x86-70.tgz + # Python dependencies COPY install/requirements /work/ RUN python -m pip install --no-cache-dir --upgrade pip && \ diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index f3b03570db33..77d0fd7f3ab0 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -163,7 +163,7 @@ build_dynamic_libmxnet() { gather_licenses cd /work/build - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable if [[ ${mxnet_variant} = "cpu" ]]; then cmake -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLDNN=ON \ @@ -329,7 +329,7 @@ build_android_armv8() { build_centos7_cpu() { set -ex cd /work/build - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable cmake \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DENABLE_TESTCOVERAGE=ON \ @@ -344,7 +344,7 @@ build_centos7_cpu() { build_centos7_cpu_make() { set -ex cd /work/mxnet - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable make \ DEV=1 \ USE_LAPACK=1 \ @@ -359,7 +359,7 @@ build_centos7_cpu_make() { build_centos7_mkldnn() { set -ex cd /work/build - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable cmake \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLDNN=ON \ @@ -371,7 +371,7 @@ build_centos7_mkldnn() { build_centos7_gpu() { set -ex cd /work/build - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable cmake \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DUSE_MKL_IF_AVAILABLE=OFF \ @@ -1107,7 +1107,7 @@ unittest_ubuntu_python3_quantization_gpu() { unittest_centos7_cpu_scala() { set -ex - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-maven35/enable cd /work/mxnet scala_prepare @@ -1929,7 +1929,7 @@ checkout() { build_static_libmxnet() { set -ex pushd . - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable export USE_SYSTEM_CUDA=1 export CMAKE_STATICBUILD=1 @@ -1942,7 +1942,7 @@ build_static_libmxnet() { cd_package_pypi() { set -ex pushd . - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable local mxnet_variant=${1:?"This function requires a python command as the first argument"} ./cd/python/pypi/pypi_package.sh ${mxnet_variant} @@ -1996,7 +1996,7 @@ build_static_scala_cpu() { scala_prepare export MAVEN_PUBLISH_OS_TYPE=linux-x86_64-cpu export mxnet_variant=cpu - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-maven35/enable ./ci/publish/scala/build.sh popd @@ -2006,7 +2006,7 @@ build_static_python_cpu() { set -ex pushd . export mxnet_variant=cpu - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd @@ -2017,7 +2017,7 @@ build_static_python_cu92() { pushd . export mxnet_variant=cu92 export USE_SYSTEM_CUDA=1 - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd @@ -2028,7 +2028,7 @@ build_static_python_cpu_cmake() { pushd . export mxnet_variant=cpu export CMAKE_STATICBUILD=1 - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd @@ -2040,7 +2040,7 @@ build_static_python_cu92_cmake() { export mxnet_variant=cu92 export CMAKE_STATICBUILD=1 export USE_SYSTEM_CUDA=1 - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd @@ -2050,7 +2050,7 @@ publish_scala_build() { set -ex pushd . scala_prepare - source /opt/rh/devtoolset-7/enable + source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-maven35/enable export USE_SYSTEM_CUDA=1 ./ci/publish/scala/build.sh diff --git a/cmake/ChooseBlas.cmake b/cmake/ChooseBlas.cmake index e16594794ae8..aff5b4313cec 100644 --- a/cmake/ChooseBlas.cmake +++ b/cmake/ChooseBlas.cmake @@ -42,6 +42,9 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open") find_package(OpenBLAS REQUIRED) include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR}) list(APPEND mshadow_LINKER_LIBS ${OpenBLAS_LIB}) + if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND UNIX AND NOT APPLE) + list(APPEND mshadow_LINKER_LIBS /usr/local/flang/lib/libflang.a /usr/local/flang/lib/libflangrti.a /usr/local/flang/lib/libpgmath.a) + endif() add_definitions(-DMSHADOW_USE_CBLAS=1) add_definitions(-DMSHADOW_USE_MKL=0) add_definitions(-DMXNET_USE_BLAS_OPEN=1) diff --git a/make/staticbuild/linux_cpu.mk b/make/staticbuild/linux_cpu.mk index 1cf389ae4a57..6b70c259020e 100644 --- a/make/staticbuild/linux_cpu.mk +++ b/make/staticbuild/linux_cpu.mk @@ -37,7 +37,7 @@ DEBUG = 0 USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -lgfortran -ldl -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -lflang -lflangrti -lpgmath -ldl -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections # the additional compile flags you want to add ADD_CFLAGS += -I$(DEPS_PATH)/include -ffunction-sections -fdata-sections diff --git a/make/staticbuild/linux_cu100.mk b/make/staticbuild/linux_cu100.mk index 855485c5b6df..cea0ddb26cf0 100644 --- a/make/staticbuild/linux_cu100.mk +++ b/make/staticbuild/linux_cu100.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu101.mk b/make/staticbuild/linux_cu101.mk index 7bbde85bee11..bfce5cb8cbd4 100644 --- a/make/staticbuild/linux_cu101.mk +++ b/make/staticbuild/linux_cu101.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu102.mk b/make/staticbuild/linux_cu102.mk index 963842a19cff..b76278f87399 100644 --- a/make/staticbuild/linux_cu102.mk +++ b/make/staticbuild/linux_cu102.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu92.mk b/make/staticbuild/linux_cu92.mk index 2cbbdd25eeaf..9af0c608872b 100644 --- a/make/staticbuild/linux_cu92.mk +++ b/make/staticbuild/linux_cu92.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_native.mk b/make/staticbuild/linux_native.mk index 348a659cd9e2..4f6d6f8d6ecb 100644 --- a/make/staticbuild/linux_native.mk +++ b/make/staticbuild/linux_native.mk @@ -37,7 +37,7 @@ DEBUG = 0 USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -lgfortran -ldl -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -lflang -lflangrti -lpgmath -ldl -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections # the additional compile flags you want to add ADD_CFLAGS += -I$(DEPS_PATH)/include -ffunction-sections -fdata-sections diff --git a/scala-package/assembly/src/main/assembly/assembly.xml b/scala-package/assembly/src/main/assembly/assembly.xml index 655c4fdb6ef2..4ea88525f267 100644 --- a/scala-package/assembly/src/main/assembly/assembly.xml +++ b/scala-package/assembly/src/main/assembly/assembly.xml @@ -55,8 +55,7 @@ libmxnet.so libtvm_runtime.so - libgfortran.so.4 - libquadmath.so.0 + libomp.so lib/native diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/util/NativeLibraryLoader.scala b/scala-package/core/src/main/scala/org/apache/mxnet/util/NativeLibraryLoader.scala index a523e2d35d19..d1c9dd5336e6 100644 --- a/scala-package/core/src/main/scala/org/apache/mxnet/util/NativeLibraryLoader.scala +++ b/scala-package/core/src/main/scala/org/apache/mxnet/util/NativeLibraryLoader.scala @@ -87,8 +87,7 @@ private[mxnet] object NativeLibraryLoader { val libFileInJar = libPathInJar + loadLibname saveLibraryToTemp("libmxnet.so", "/lib/native/libmxnet.so", true) saveLibraryToTemp("libtvm_runtime.so", "/lib/native/libtvm_runtime.so", false) - saveLibraryToTemp("libgfortran.so.4", "/lib/native/libgfortran.so.4", false) - saveLibraryToTemp("libquadmath.so.0", "/lib/native/libquadmath.so.0", false) + saveLibraryToTemp("libomp.so", "/lib/native/libomp.so", false) val tempfile: File = saveLibraryToTemp(libname, libFileInJar, true) loadLibraryFromFile(libname, tempfile) diff --git a/tools/dependencies/LICENSE.binary.dependencies b/tools/dependencies/LICENSE.binary.dependencies index c9202bac98e2..e4fdf4a0f2d6 100644 --- a/tools/dependencies/LICENSE.binary.dependencies +++ b/tools/dependencies/LICENSE.binary.dependencies @@ -9,10 +9,14 @@ ======================================================================================= 1. cityhash - For details, see https://github.com/google/cityhash/blob/master/COPYING - Copyright (c) 2011 Google, Inc. + Copyright (c) 2011 Google, Inc. + 2. protobuf - For details, see https://github.com/protocolbuffers/protobuf/blob/master/LICENSE Copyright 2008 Google Inc. All rights reserved. + 3. llvm openmp - For details, see https://github.com/llvm/llvm-project/blob/release/7.x/openmp/LICENSE.txt + Copyright (c) 1997-2016 Intel Corporation All rights reserved. + ======================================================================================= Mozilla Public License Version 2.0 ======================================================================================= @@ -51,6 +55,12 @@ Copyright (c) 1998-2018 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson + 2. flang - For details, see https://github.com/flang-compiler/flang/blob/flang_20190329/LICENSE.txt + Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + + 3. pgmath - For details, see https://github.com/flang-compiler/flang/blob/flang_20190329/runtime/libpgmath/LICENSE.txt + Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + ======================================================================================= Other Licenses ======================================================================================= diff --git a/tools/dependencies/README.md b/tools/dependencies/README.md index c898112c3c93..ae591b143852 100644 --- a/tools/dependencies/README.md +++ b/tools/dependencies/README.md @@ -85,8 +85,6 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ - gfortran \ - gfortran-4.8 \ binutils \ nasm \ libtool \ @@ -259,8 +257,6 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ - gfortran \ - gfortran-4.8 \ binutils \ nasm \ libtool \ @@ -308,8 +304,6 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ - gfortran \ - gfortran-4.8 \ binutils \ nasm \ libtool \ diff --git a/tools/dependencies/libpng.sh b/tools/dependencies/libpng.sh index 39fa24c87ecd..24de54e5521b 100755 --- a/tools/dependencies/libpng.sh +++ b/tools/dependencies/libpng.sh @@ -20,7 +20,7 @@ # This script builds the static library of libpng that can be used as dependency of mxnet/opencv. set -ex PNG_VERSION=1.6.35 -if [[ ! -f $DEPS_PATH/lib/libpng.a ]]; then +if [[ ! -f $DEPS_PATH/lib/libpng.a ]] && [[ ! -f $DEPS_PATH/lib64/libpng.a ]]; then # download and build libpng >&2 echo "Building libpng..." download \ diff --git a/tools/dependencies/libturbojpeg.sh b/tools/dependencies/libturbojpeg.sh index 911827a16fcf..4cce416c190e 100755 --- a/tools/dependencies/libturbojpeg.sh +++ b/tools/dependencies/libturbojpeg.sh @@ -25,7 +25,8 @@ if [[ $PLATFORM == 'darwin' ]]; then JPEG_NASM_OPTION="-D CMAKE_ASM_NASM_COMPILER=/usr/local/bin/nasm" fi -if [[ ! -f $DEPS_PATH/lib/libjpeg.a ]] || [[ ! -f $DEPS_PATH/lib/libturbojpeg.a ]]; then +if [[ ( ! -f $DEPS_PATH/lib/libjpeg.a ) || ( ! -f $DEPS_PATH/lib/libturbojpeg.a ) ]] && \ + [[ ( ! -f $DEPS_PATH/lib64/libjpeg.a ) || ( ! -f $DEPS_PATH/lib64/libturbojpeg.a ) ]]; then # download and build libjpeg >&2 echo "Building libjpeg-turbo..." download \ diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh index dad566ff877d..5db9236a870f 100755 --- a/tools/dependencies/openblas.sh +++ b/tools/dependencies/openblas.sh @@ -20,8 +20,7 @@ # This script builds the static library of openblas that can be used as dependency of mxnet. set -ex OPENBLAS_VERSION=4a4c50a7cef9fa91f14e508722f502d956ad5192 -if [[ ((! -e $DEPS_PATH/lib/libopenblas.a) && -z "$CMAKE_STATICBUILD") || - ((! -e $DEPS_PATH/lib/libopenblas.so) && -v CMAKE_STATICBUILD) ]]; then +if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then # download and build openblas >&2 echo "Building openblas..." @@ -33,25 +32,14 @@ if [[ ((! -e $DEPS_PATH/lib/libopenblas.a) && -z "$CMAKE_STATICBUILD") || cd $DEPS_PATH/OpenBLAS-${OPENBLAS_VERSION} # Adding NO_DYNAMIC=1 flag causes make install to fail - CXX="g++ -fPIC" CC="gcc -fPIC" $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 - - if [[ -v CMAKE_STATICBUILD ]]; then - # We link and redistribute libopenblas.so for cmake staticbuild - # cf https://gitlab.kitware.com/cmake/cmake/issues/16221#note_143330 - patchelf --set-rpath '$ORIGIN' --force-rpath libopenblas.so - fi + CXX="clang++ -fPIC" CC="clang -fPIC" LD_LIBRARY_PATH="/usr/local/flang/lib:$LD_LIBRARY_PATH" \ + LDFLAGS="-L/usr/local/flang/lib" CFLAGS="-I/usr/local/flang/include" \ + $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 $MAKE PREFIX=$DEPS_PATH install - - if [[ -z "$CMAKE_STATICBUILD" ]]; then - # Manually removing .so to avoid linking against it - rm $DEPS_PATH/lib/libopenblas*.so - fi + # Manually removing .so to avoid linking against it + rm $DEPS_PATH/lib/libopenblas*.so popd - if [[ -z "$CMAKE_STATICBUILD" ]]; then - ln -s libopenblas.a $DEPS_PATH/lib/libcblas.a - ln -s libopenblas.a $DEPS_PATH/lib/liblapack.a - fi fi diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh index 139b68c5bef0..ab769ad0361a 100755 --- a/tools/dependencies/opencv.sh +++ b/tools/dependencies/opencv.sh @@ -46,7 +46,7 @@ if [[ ! -f $DEPS_PATH/lib/libopencv_core.a ]] || [[ ! -f $DEPS_PATH/lib/libopenc mkdir -p $DEPS_PATH/opencv-$OPENCV_VERSION/build pushd . cd $DEPS_PATH/opencv-$OPENCV_VERSION/build - CXX="g++ -fPIC" CC="gcc -fPIC" cmake \ + CXX="clang++ -fPIC" CC="clang -fPIC" cmake \ -D OPENCV_ENABLE_NONFREE=OFF \ -D WITH_1394=OFF \ -D WITH_ARAVIS=OFF \ diff --git a/tools/dependencies/openssl.sh b/tools/dependencies/openssl.sh index 78673a3ac84b..8e1456e02281 100755 --- a/tools/dependencies/openssl.sh +++ b/tools/dependencies/openssl.sh @@ -20,7 +20,8 @@ # This script builds the static library of openssl that can be used as dependency of mxnet. set -ex OPENSSL_VERSION=1.1.1b -if [[ ! -f $DEPS_PATH/lib/libssl.a ]] || [[ ! -f $DEPS_PATH/lib/libcrypto.a ]]; then +if [[ ( ! -f $DEPS_PATH/lib/libssl.a ) || ( ! -f $DEPS_PATH/lib/libcrypto.a ) ]] && \ + [[ ( ! -f $DEPS_PATH/lib64/libssl.a ) || ( ! -f $DEPS_PATH/lib64/libcrypto.a ) ]]; then # download and build openssl >&2 echo "Building openssl..." OPENSSL_VERSION=$(echo $OPENSSL_VERSION | sed 's/\./_/g') diff --git a/tools/dependencies/protobuf.sh b/tools/dependencies/protobuf.sh index 7da4c2537b42..7accf4560e2b 100755 --- a/tools/dependencies/protobuf.sh +++ b/tools/dependencies/protobuf.sh @@ -19,7 +19,7 @@ # This script builds the static library of protobuf along with protoc, that can be used as dependency of mxnet. set -ex -PROTOBUF_VERSION=3.5.1 +PROTOBUF_VERSION=3.12.3 if [[ $PLATFORM == 'darwin' ]]; then DY_EXT="dylib" else @@ -32,13 +32,14 @@ if [[ ! -e $LIBPROTOBUF ]] || [[ ! -e $LIBPROTOC ]]; then # Download and build protobuf >&2 echo "Building protobuf..." download \ - https://github.com/google/protobuf/archive/v${PROTOBUF_VERSION}.zip \ + https://github.com/protocolbuffers/protobuf/archive/v${PROTOBUF_VERSION}.zip \ ${DEPS_PATH}/protobuf.zip unzip -q $DEPS_PATH/protobuf.zip -d $DEPS_PATH pushd . cd $DEPS_PATH/protobuf-$PROTOBUF_VERSION ./autogen.sh - ./configure -prefix=$DEPS_PATH + # Need to find /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/cc1plus + PATH=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/:$PATH ./configure -prefix=$DEPS_PATH $MAKE $MAKE install popd diff --git a/tools/pip/setup.py b/tools/pip/setup.py index 2377e6177641..c5fbb934e2b9 100644 --- a/tools/pip/setup.py +++ b/tools/pip/setup.py @@ -153,17 +153,8 @@ def skip_markdown_comments(md): os.path.join(CURRENT_DIR, 'mxnet/include/mkldnn')) if platform.system() == 'Linux': libdir, mxdir = os.path.dirname(LIB_PATH[0]), os.path.join(CURRENT_DIR, 'mxnet') - if os.path.exists(os.path.join(libdir, 'libgfortran.so.3')): - shutil.copy(os.path.join(libdir, 'libgfortran.so.3'), mxdir) - package_data['mxnet'].append('mxnet/libgfortran.so.3') - else: - shutil.copy(os.path.join(libdir, 'libgfortran.so.4'), mxdir) - package_data['mxnet'].append('mxnet/libgfortran.so.4') - shutil.copy(os.path.join(libdir, 'libquadmath.so.0'), mxdir) - package_data['mxnet'].append('mxnet/libquadmath.so.0') - if os.path.exists(os.path.join(libdir, 'libopenblas.so.0')): - shutil.copy(os.path.join(libdir, 'libopenblas.so.0'), mxdir) - package_data['mxnet'].append('mxnet/libquadmath.so.0') + shutil.copy(os.path.join(libdir, 'libomp.so'), mxdir) + package_data['mxnet'].append('mxnet/libomp.so') # Copy licenses and notice for f in os.listdir('mxnet/licenses'): diff --git a/tools/staticbuild/build.sh b/tools/staticbuild/build.sh index e5fd24368ed3..c24c77f96675 100755 --- a/tools/staticbuild/build.sh +++ b/tools/staticbuild/build.sh @@ -48,9 +48,9 @@ else fi export MAKE="make $ADD_MAKE_FLAG" -export CC="gcc -fPIC -mno-avx" -export CXX="g++ -fPIC -mno-avx" -export FC="gfortran" +export CC="clang -fPIC -mno-avx" +export CXX="clang++ -fPIC -mno-avx" +export FC="/usr/local/flang/bin/flang" export PKG_CONFIG_PATH=$DEPS_PATH/lib/pkgconfig:$DEPS_PATH/lib64/pkgconfig:$DEPS_PATH/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH export CPATH=$DEPS_PATH/include:$CPATH diff --git a/tools/staticbuild/build_lib.sh b/tools/staticbuild/build_lib.sh index 989070ac7078..3112d9e628ca 100755 --- a/tools/staticbuild/build_lib.sh +++ b/tools/staticbuild/build_lib.sh @@ -40,8 +40,7 @@ $MAKE DEPS_PATH=$DEPS_PATH mkldnn $MAKE DEPS_PATH=$DEPS_PATH if [[ $PLATFORM == 'linux' ]]; then - cp -L $(ldd lib/libmxnet.so | grep libgfortran | awk '{print $3}') lib/ - cp -L $(ldd lib/libmxnet.so | grep libquadmath | awk '{print $3}') lib/ + cp -L $(ldd lib/libmxnet.so | grep libomp | awk '{print $3}') lib/ fi # Print the linked objects on libmxnet.so diff --git a/tools/staticbuild/build_lib_cmake.sh b/tools/staticbuild/build_lib_cmake.sh index 5261b2a6942a..19edb8617b1a 100755 --- a/tools/staticbuild/build_lib_cmake.sh +++ b/tools/staticbuild/build_lib_cmake.sh @@ -38,9 +38,7 @@ cd - rm -rf lib; mkdir lib; if [[ $PLATFORM == 'linux' ]]; then cp -L build/libmxnet.so lib/libmxnet.so - cp -L staticdeps/lib/libopenblas.so lib/libopenblas.so.0 - cp -L $(ldd lib/libmxnet.so | grep libgfortran | awk '{print $3}') lib/ - cp -L $(ldd lib/libmxnet.so | grep libquadmath | awk '{print $3}') lib/ + cp -L $(ldd lib/libmxnet.so | grep libomp | awk '{print $3}') lib/ elif [[ $PLATFORM == 'darwin' ]]; then cp -L build/libmxnet.dylib lib/libmxnet.dylib fi From 8a12d793c10e83f81cd1d81aea8babfa558a8990 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 9 Jun 2020 04:17:26 +0000 Subject: [PATCH 3/9] ps-lite -Wno-error=overloaded-virtual --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f82bd3e48ba..ff56ef2740f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -776,6 +776,7 @@ endif() if(USE_DIST_KVSTORE) add_subdirectory("3rdparty/ps-lite") + target_compile_options(mxnet PRIVATE "$<$:-Wno-error=overloaded-virtual>") add_definitions(-DMXNET_USE_DIST_KVSTORE) list(APPEND mxnet_LINKER_LIBS pslite) endif() From d5866e4d548f890fcf00243509ba162da5eddfaf Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 9 Jun 2020 02:25:58 +0000 Subject: [PATCH 4/9] Fix segfaults --- ci/docker/Dockerfile.build.centos7 | 9 ++++++++- tools/dependencies/openblas.sh | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/docker/Dockerfile.build.centos7 b/ci/docker/Dockerfile.build.centos7 index 325878d744a9..c38201b93364 100644 --- a/ci/docker/Dockerfile.build.centos7 +++ b/ci/docker/Dockerfile.build.centos7 @@ -122,10 +122,17 @@ RUN export SHORT_CUDA_VERSION=${CUDA_VERSION%.*} && \ # runtime dependency on libgfortran.so which is GPL-licensed and thus # https://www.apache.org/legal/resolved.html#category-x for distribution. # We need a Fortran compiler to compile the OpenBLAS Lapack implementation. +# NOTE: The flang toolchain also provides llvm libomp.so and libomp.a. We must +# use the libomp provided by flang for all parts of the project, to avoid +# linking multiple omp implementations. Linking 2 different llvm omp's would +# cause segfaults on importing mxnet. In the next step we'll install compatible +# omp headers. RUN cd /usr/local/ && mkdir flang && cd flang && \ wget -nv https://github.com/flang-compiler/flang/releases/download/flang_20190329/flang-20190329-x86-70.tgz && \ tar xf flang-20190329-x86-70.tgz && \ - rm flang-20190329-x86-70.tgz + rm flang-20190329-x86-70.tgz && \ + # IMPORTANT: Replace libomp.so with the flang version, to avoid segfault upon importing MXNet + cp /usr/local/flang/lib/libomp.so /opt/rh/llvm-toolset-7.0/root/usr/lib64/libomp.so # Python dependencies COPY install/requirements /work/ diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh index 5db9236a870f..f44eb59d51ce 100755 --- a/tools/dependencies/openblas.sh +++ b/tools/dependencies/openblas.sh @@ -19,7 +19,7 @@ # This script builds the static library of openblas that can be used as dependency of mxnet. set -ex -OPENBLAS_VERSION=4a4c50a7cef9fa91f14e508722f502d956ad5192 +OPENBLAS_VERSION=f7659be4a0e05404b251f17a0eefeabb7d31b284 if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then # download and build openblas >&2 echo "Building openblas..." From 21907327c93c4e5966c346ba32494aa83cba2ef8 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 9 Jun 2020 04:04:39 +0000 Subject: [PATCH 5/9] Use LLVM Flang toolchain only for CPU builds Cuda 9.2 misses LLVM 7 support. Switch cuda builds in a separate commit, to simplify backporting of CPU changes. --- ci/docker/Dockerfile.build.centos7 | 1 + ci/docker/runtime_functions.sh | 14 +++++++++----- cmake/ChooseBlas.cmake | 2 +- make/staticbuild/linux_cu100.mk | 4 ++-- make/staticbuild/linux_cu101.mk | 4 ++-- make/staticbuild/linux_cu102.mk | 4 ++-- make/staticbuild/linux_cu92.mk | 4 ++-- tools/dependencies/README.md | 6 ++++++ tools/dependencies/openblas.sh | 10 +++++++--- tools/dependencies/opencv.sh | 2 +- tools/pip/setup.py | 17 +++++++++++++++-- tools/staticbuild/build.sh | 16 +++++++++++++--- tools/staticbuild/build_lib.sh | 5 ++++- tools/staticbuild/build_lib_cmake.sh | 5 ++++- 14 files changed, 69 insertions(+), 25 deletions(-) diff --git a/ci/docker/Dockerfile.build.centos7 b/ci/docker/Dockerfile.build.centos7 index c38201b93364..9c0ba8199b34 100644 --- a/ci/docker/Dockerfile.build.centos7 +++ b/ci/docker/Dockerfile.build.centos7 @@ -52,6 +52,7 @@ RUN yum -y check-update || true && \ protobuf-compiler \ protobuf-devel \ # CentOS Software Collections https://www.softwarecollections.org + devtoolset-7 \ llvm-toolset-7.0 \ llvm-toolset-7.0-libomp-devel \ rh-python36 \ diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 77d0fd7f3ab0..c9c35a05deb4 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -371,7 +371,7 @@ build_centos7_mkldnn() { build_centos7_gpu() { set -ex cd /work/build - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable cmake \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DUSE_MKL_IF_AVAILABLE=OFF \ @@ -1929,11 +1929,15 @@ checkout() { build_static_libmxnet() { set -ex pushd . - source /opt/rh/llvm-toolset-7.0/enable - source /opt/rh/rh-python36/enable export USE_SYSTEM_CUDA=1 export CMAKE_STATICBUILD=1 local mxnet_variant=${1:?"This function requires a python command as the first argument"} + if [[ $mxnet_variant == cu* ]]; then + source /opt/rh/devtoolset-7/enable + else + source /opt/rh/llvm-toolset-7.0/enable + fi + source /opt/rh/rh-python36/enable source tools/staticbuild/build.sh ${mxnet_variant} popd } @@ -2017,7 +2021,7 @@ build_static_python_cu92() { pushd . export mxnet_variant=cu92 export USE_SYSTEM_CUDA=1 - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd @@ -2040,7 +2044,7 @@ build_static_python_cu92_cmake() { export mxnet_variant=cu92 export CMAKE_STATICBUILD=1 export USE_SYSTEM_CUDA=1 - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable source /opt/rh/rh-python36/enable ./ci/publish/python/build.sh popd diff --git a/cmake/ChooseBlas.cmake b/cmake/ChooseBlas.cmake index aff5b4313cec..0fa756c7d267 100644 --- a/cmake/ChooseBlas.cmake +++ b/cmake/ChooseBlas.cmake @@ -42,7 +42,7 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open") find_package(OpenBLAS REQUIRED) include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR}) list(APPEND mshadow_LINKER_LIBS ${OpenBLAS_LIB}) - if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND UNIX AND NOT APPLE) + if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND $ENV{FC} MATCHES "flang") list(APPEND mshadow_LINKER_LIBS /usr/local/flang/lib/libflang.a /usr/local/flang/lib/libflangrti.a /usr/local/flang/lib/libpgmath.a) endif() add_definitions(-DMSHADOW_USE_CBLAS=1) diff --git a/make/staticbuild/linux_cu100.mk b/make/staticbuild/linux_cu100.mk index cea0ddb26cf0..855485c5b6df 100644 --- a/make/staticbuild/linux_cu100.mk +++ b/make/staticbuild/linux_cu100.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu101.mk b/make/staticbuild/linux_cu101.mk index bfce5cb8cbd4..7bbde85bee11 100644 --- a/make/staticbuild/linux_cu101.mk +++ b/make/staticbuild/linux_cu101.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu102.mk b/make/staticbuild/linux_cu102.mk index b76278f87399..963842a19cff 100644 --- a/make/staticbuild/linux_cu102.mk +++ b/make/staticbuild/linux_cu102.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/make/staticbuild/linux_cu92.mk b/make/staticbuild/linux_cu92.mk index 9af0c608872b..2cbbdd25eeaf 100644 --- a/make/staticbuild/linux_cu92.mk +++ b/make/staticbuild/linux_cu92.mk @@ -38,9 +38,9 @@ USE_SIGNAL_HANDLER = 1 # the additional link flags you want to add ifdef USE_SYSTEM_CUDA -ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections else -ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lflang -lflangrti -lpgmath -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections +ADD_LDFLAGS += -L$(DEPS_PATH)/lib $(DEPS_PATH)/lib/libculibos.a -lpng -ltiff -ljpeg -lz -ldl -lgfortran -Wl,--version-script=$(CURDIR)/make/config/libmxnet.ver,-rpath,'$${ORIGIN}',--gc-sections endif # the additional compile flags you want to add diff --git a/tools/dependencies/README.md b/tools/dependencies/README.md index ae591b143852..c898112c3c93 100644 --- a/tools/dependencies/README.md +++ b/tools/dependencies/README.md @@ -85,6 +85,8 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ + gfortran \ + gfortran-4.8 \ binutils \ nasm \ libtool \ @@ -257,6 +259,8 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ + gfortran \ + gfortran-4.8 \ binutils \ nasm \ libtool \ @@ -304,6 +308,8 @@ sudo apt-get install -y git \ unzip \ gcc-4.8 \ g++-4.8 \ + gfortran \ + gfortran-4.8 \ binutils \ nasm \ libtool \ diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh index f44eb59d51ce..ad9e2d3fe588 100755 --- a/tools/dependencies/openblas.sh +++ b/tools/dependencies/openblas.sh @@ -32,9 +32,13 @@ if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then cd $DEPS_PATH/OpenBLAS-${OPENBLAS_VERSION} # Adding NO_DYNAMIC=1 flag causes make install to fail - CXX="clang++ -fPIC" CC="clang -fPIC" LD_LIBRARY_PATH="/usr/local/flang/lib:$LD_LIBRARY_PATH" \ - LDFLAGS="-L/usr/local/flang/lib" CFLAGS="-I/usr/local/flang/include" \ - $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 + if [[ "$FC" == *"flang"* ]]; then + LD_LIBRARY_PATH="/usr/local/flang/lib:$LD_LIBRARY_PATH" \ + LDFLAGS="-L/usr/local/flang/lib" CFLAGS="-I/usr/local/flang/include" \ + $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 + else + $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 + fi $MAKE PREFIX=$DEPS_PATH install diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh index ab769ad0361a..eb4730c505ed 100755 --- a/tools/dependencies/opencv.sh +++ b/tools/dependencies/opencv.sh @@ -46,7 +46,7 @@ if [[ ! -f $DEPS_PATH/lib/libopencv_core.a ]] || [[ ! -f $DEPS_PATH/lib/libopenc mkdir -p $DEPS_PATH/opencv-$OPENCV_VERSION/build pushd . cd $DEPS_PATH/opencv-$OPENCV_VERSION/build - CXX="clang++ -fPIC" CC="clang -fPIC" cmake \ + cmake \ -D OPENCV_ENABLE_NONFREE=OFF \ -D WITH_1394=OFF \ -D WITH_ARAVIS=OFF \ diff --git a/tools/pip/setup.py b/tools/pip/setup.py index c5fbb934e2b9..07295258fa96 100644 --- a/tools/pip/setup.py +++ b/tools/pip/setup.py @@ -153,8 +153,21 @@ def skip_markdown_comments(md): os.path.join(CURRENT_DIR, 'mxnet/include/mkldnn')) if platform.system() == 'Linux': libdir, mxdir = os.path.dirname(LIB_PATH[0]), os.path.join(CURRENT_DIR, 'mxnet') - shutil.copy(os.path.join(libdir, 'libomp.so'), mxdir) - package_data['mxnet'].append('mxnet/libomp.so') + if os.path.exists(os.path.join(libdir, 'libgfortran.so.3')): + shutil.copy(os.path.join(libdir, 'libgfortran.so.3'), mxdir) + package_data['mxnet'].append('mxnet/libgfortran.so.3') + else: + shutil.copy(os.path.join(libdir, 'libgfortran.so.4'), mxdir) + package_data['mxnet'].append('mxnet/libgfortran.so.4') + if os.path.exists(os.path.join(libdir, 'libquadmath.so.0')): + shutil.copy(os.path.join(libdir, 'libquadmath.so.0'), mxdir) + package_data['mxnet'].append('mxnet/libquadmath.so.0') + if os.path.exists(os.path.join(libdir, 'libopenblas.so.0')): + shutil.copy(os.path.join(libdir, 'libopenblas.so.0'), mxdir) + package_data['mxnet'].append('mxnet/libquadmath.so.0') + if os.path.exists(os.path.join(libdir, 'libomp.so')): + shutil.copy(os.path.join(libdir, 'libomp.so'), mxdir) + package_data['mxnet'].append('mxnet/libomp.so') # Copy licenses and notice for f in os.listdir('mxnet/licenses'): diff --git a/tools/staticbuild/build.sh b/tools/staticbuild/build.sh index c24c77f96675..32c34d9b8a03 100755 --- a/tools/staticbuild/build.sh +++ b/tools/staticbuild/build.sh @@ -48,9 +48,19 @@ else fi export MAKE="make $ADD_MAKE_FLAG" -export CC="clang -fPIC -mno-avx" -export CXX="clang++ -fPIC -mno-avx" -export FC="/usr/local/flang/bin/flang" +if [[ $VARIANT != cu* ]]; then + export CC="clang" + export CXX="clang++" + export CFLAGS="-fPIC -mno-avx" + export CXXFLAGS="-fPIC -mno-avx" + export FC="/usr/local/flang/bin/flang" +else + export CC="gcc" + export CXX="g++" + export CFLAGS="-fPIC -mno-avx" + export CXXFLAGS="-fPIC -mno-avx" + export FC="gfortran" +fi export PKG_CONFIG_PATH=$DEPS_PATH/lib/pkgconfig:$DEPS_PATH/lib64/pkgconfig:$DEPS_PATH/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH export CPATH=$DEPS_PATH/include:$CPATH diff --git a/tools/staticbuild/build_lib.sh b/tools/staticbuild/build_lib.sh index 3112d9e628ca..2606185bd689 100755 --- a/tools/staticbuild/build_lib.sh +++ b/tools/staticbuild/build_lib.sh @@ -39,8 +39,11 @@ $MAKE DEPS_PATH=$DEPS_PATH mkldnn >&2 echo "Now building mxnet..." $MAKE DEPS_PATH=$DEPS_PATH -if [[ $PLATFORM == 'linux' ]]; then +if [[ ( $PLATFORM == 'linux' ) && ( "$FC" == *"flang"* ) ]]; then cp -L $(ldd lib/libmxnet.so | grep libomp | awk '{print $3}') lib/ +elif [[ $PLATFORM == 'linux' ]]; then + cp -L $(ldd lib/libmxnet.so | grep libgfortran | awk '{print $3}') lib/ + cp -L $(ldd lib/libmxnet.so | grep libquadmath | awk '{print $3}') lib/ fi # Print the linked objects on libmxnet.so diff --git a/tools/staticbuild/build_lib_cmake.sh b/tools/staticbuild/build_lib_cmake.sh index 19edb8617b1a..94ced905f938 100755 --- a/tools/staticbuild/build_lib_cmake.sh +++ b/tools/staticbuild/build_lib_cmake.sh @@ -36,9 +36,12 @@ cd - # Move to lib rm -rf lib; mkdir lib; -if [[ $PLATFORM == 'linux' ]]; then +if [[ ( $PLATFORM == 'linux' ) && ( "$FC" == *"flang"* ) ]]; then cp -L build/libmxnet.so lib/libmxnet.so cp -L $(ldd lib/libmxnet.so | grep libomp | awk '{print $3}') lib/ +elif [[ $PLATFORM == 'linux' ]]; then + cp -L $(ldd lib/libmxnet.so | grep libgfortran | awk '{print $3}') lib/ + cp -L $(ldd lib/libmxnet.so | grep libquadmath | awk '{print $3}') lib/ elif [[ $PLATFORM == 'darwin' ]]; then cp -L build/libmxnet.dylib lib/libmxnet.dylib fi From f031c5fb3bb5ec0910925201895b6441f8fe9c8a Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 9 Jun 2020 22:42:47 +0000 Subject: [PATCH 6/9] Fixes --- ci/docker/runtime_functions.sh | 2 +- cmake/ChooseBlas.cmake | 6 ++++-- tools/dependencies/openblas.sh | 4 ++-- tools/dependencies/opencv.sh | 2 +- tools/staticbuild/build.sh | 14 +++++++------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index c9c35a05deb4..68714d7b18b1 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -344,7 +344,7 @@ build_centos7_cpu() { build_centos7_cpu_make() { set -ex cd /work/mxnet - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable make \ DEV=1 \ USE_LAPACK=1 \ diff --git a/cmake/ChooseBlas.cmake b/cmake/ChooseBlas.cmake index 0fa756c7d267..ba14e7038551 100644 --- a/cmake/ChooseBlas.cmake +++ b/cmake/ChooseBlas.cmake @@ -42,8 +42,10 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open") find_package(OpenBLAS REQUIRED) include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR}) list(APPEND mshadow_LINKER_LIBS ${OpenBLAS_LIB}) - if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND $ENV{FC} MATCHES "flang") - list(APPEND mshadow_LINKER_LIBS /usr/local/flang/lib/libflang.a /usr/local/flang/lib/libflangrti.a /usr/local/flang/lib/libpgmath.a) + if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND DEFINED ENV{FC}) + if($ENV{"FC"} MATCHES "flang") + list(APPEND mshadow_LINKER_LIBS /usr/local/flang/lib/libflang.a /usr/local/flang/lib/libflangrti.a /usr/local/flang/lib/libpgmath.a) + endif() endif() add_definitions(-DMSHADOW_USE_CBLAS=1) add_definitions(-DMSHADOW_USE_MKL=0) diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh index ad9e2d3fe588..7b83baa1ad5b 100755 --- a/tools/dependencies/openblas.sh +++ b/tools/dependencies/openblas.sh @@ -35,9 +35,9 @@ if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then if [[ "$FC" == *"flang"* ]]; then LD_LIBRARY_PATH="/usr/local/flang/lib:$LD_LIBRARY_PATH" \ LDFLAGS="-L/usr/local/flang/lib" CFLAGS="-I/usr/local/flang/include" \ - $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 + CFLAGS="-fPIC" CXXFLAGS="-fPIC" $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 else - $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 + CFLAGS="-fPIC" CXXFLAGS="-fPIC" $MAKE DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_OPENMP=1 fi $MAKE PREFIX=$DEPS_PATH install diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh index eb4730c505ed..56707261ecfa 100755 --- a/tools/dependencies/opencv.sh +++ b/tools/dependencies/opencv.sh @@ -46,7 +46,7 @@ if [[ ! -f $DEPS_PATH/lib/libopencv_core.a ]] || [[ ! -f $DEPS_PATH/lib/libopenc mkdir -p $DEPS_PATH/opencv-$OPENCV_VERSION/build pushd . cd $DEPS_PATH/opencv-$OPENCV_VERSION/build - cmake \ + CFLAGS="-fPIC" CXXFLAGS="-fPIC" cmake \ -D OPENCV_ENABLE_NONFREE=OFF \ -D WITH_1394=OFF \ -D WITH_ARAVIS=OFF \ diff --git a/tools/staticbuild/build.sh b/tools/staticbuild/build.sh index 32c34d9b8a03..786f93425a92 100755 --- a/tools/staticbuild/build.sh +++ b/tools/staticbuild/build.sh @@ -48,18 +48,18 @@ else fi export MAKE="make $ADD_MAKE_FLAG" -if [[ $VARIANT != cu* ]]; then - export CC="clang" - export CXX="clang++" - export CFLAGS="-fPIC -mno-avx" - export CXXFLAGS="-fPIC -mno-avx" - export FC="/usr/local/flang/bin/flang" -else +if [[ $VARIANT == cu* ]]; then export CC="gcc" export CXX="g++" export CFLAGS="-fPIC -mno-avx" export CXXFLAGS="-fPIC -mno-avx" export FC="gfortran" +else + export CC="clang" + export CXX="clang++" + export CFLAGS="-fPIC -mno-avx" + export CXXFLAGS="-fPIC -mno-avx" + export FC="/usr/local/flang/bin/flang" fi export PKG_CONFIG_PATH=$DEPS_PATH/lib/pkgconfig:$DEPS_PATH/lib64/pkgconfig:$DEPS_PATH/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH export CPATH=$DEPS_PATH/include:$CPATH From 6444630356357b21e7642a964f9ed0bdd07208b5 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 9 Jun 2020 23:28:13 +0000 Subject: [PATCH 7/9] More fixes - Update Jenkins_pipeline.groovy after keeping GPU builds on gfortran - Use llvm flang toolchain only for staticbuild. Some bug causes object file size explosion in the non-static build script. 1013M build/CMakeFiles/mxnet.dir/src/operator/numpy/np_elemwise_broadcast_logic_op.cc.o 1.3G build/CMakeFiles/mxnet.dir/src/operator/numpy/np_where_op.cc.o 1.9G build/CMakeFiles/mxnet.dir/src/operator/numpy/np_broadcast_reduce_op_value.cc.o 2.1G build/CMakeFiles/mxnet.dir/src/operator/numpy/linalg/np_norm_forward.cc.o --- cd/mxnet_lib/static/Jenkins_pipeline.groovy | 4 ++-- ci/docker/runtime_functions.sh | 9 ++++----- cmake/ChooseBlas.cmake | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cd/mxnet_lib/static/Jenkins_pipeline.groovy b/cd/mxnet_lib/static/Jenkins_pipeline.groovy index 8da0512d9a53..8e1e4eff1c58 100644 --- a/cd/mxnet_lib/static/Jenkins_pipeline.groovy +++ b/cd/mxnet_lib/static/Jenkins_pipeline.groovy @@ -32,8 +32,8 @@ libmxnet = 'lib/libmxnet.so' licenses = 'licenses/*' // libmxnet dependencies -mx_native_deps = 'lib/libomp.so' -mx_deps = 'lib/libomp.so, include/mkldnn/dnnl_version.h, include/mkldnn/dnnl_config.h' +mx_native_deps = 'lib/libgfortran.so.4, lib/libquadmath.so.0, lib/libopenblas.so.0, lib/libomp.so' +mx_deps = 'lib/libgfortran.so.4, lib/libquadmath.so.0, lib/libopenblas.so.0, lib/libomp.so, include/mkldnn/dnnl_version.h, include/mkldnn/dnnl_config.h' // library type // either static or dynamic - depending on how it links to its dependencies diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 68714d7b18b1..9721add52e25 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -162,8 +162,8 @@ build_dynamic_libmxnet() { # relevant licenses will be placed in the licenses directory gather_licenses + source /opt/rh/devtoolset-7/enable cd /work/build - source /opt/rh/llvm-toolset-7.0/enable if [[ ${mxnet_variant} = "cpu" ]]; then cmake -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLDNN=ON \ @@ -329,7 +329,7 @@ build_android_armv8() { build_centos7_cpu() { set -ex cd /work/build - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable cmake \ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ -DENABLE_TESTCOVERAGE=ON \ @@ -359,7 +359,7 @@ build_centos7_cpu_make() { build_centos7_mkldnn() { set -ex cd /work/build - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable cmake \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLDNN=ON \ @@ -1107,7 +1107,7 @@ unittest_ubuntu_python3_quantization_gpu() { unittest_centos7_cpu_scala() { set -ex - source /opt/rh/llvm-toolset-7.0/enable + source /opt/rh/devtoolset-7/enable source /opt/rh/rh-maven35/enable cd /work/mxnet scala_prepare @@ -1946,7 +1946,6 @@ build_static_libmxnet() { cd_package_pypi() { set -ex pushd . - source /opt/rh/llvm-toolset-7.0/enable source /opt/rh/rh-python36/enable local mxnet_variant=${1:?"This function requires a python command as the first argument"} ./cd/python/pypi/pypi_package.sh ${mxnet_variant} diff --git a/cmake/ChooseBlas.cmake b/cmake/ChooseBlas.cmake index ba14e7038551..d35aa6cefed1 100644 --- a/cmake/ChooseBlas.cmake +++ b/cmake/ChooseBlas.cmake @@ -43,7 +43,7 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open") include_directories(SYSTEM ${OpenBLAS_INCLUDE_DIR}) list(APPEND mshadow_LINKER_LIBS ${OpenBLAS_LIB}) if(CMAKE_BUILD_TYPE STREQUAL "Distribution" AND DEFINED ENV{FC}) - if($ENV{"FC"} MATCHES "flang") + if($ENV{FC} MATCHES "flang") list(APPEND mshadow_LINKER_LIBS /usr/local/flang/lib/libflang.a /usr/local/flang/lib/libflangrti.a /usr/local/flang/lib/libpgmath.a) endif() endif() From a7826b2940eced7adb146b5e9142528b4dd31cda Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Wed, 10 Jun 2020 18:15:14 +0000 Subject: [PATCH 8/9] Fix OpenCV build We can't delete this hack when supporting the Makefile build: ln -s libopenblas.a $DEPS_PATH/lib/libcblas.a ln -s libopenblas.a $DEPS_PATH/lib/liblapack.a --- ci/docker/Dockerfile.build.centos7 | 3 +-- tools/dependencies/openblas.sh | 7 +++++++ tools/dependencies/opencv.sh | 2 +- tools/staticbuild/build.sh | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ci/docker/Dockerfile.build.centos7 b/ci/docker/Dockerfile.build.centos7 index 9c0ba8199b34..bc4a68994694 100644 --- a/ci/docker/Dockerfile.build.centos7 +++ b/ci/docker/Dockerfile.build.centos7 @@ -71,8 +71,7 @@ RUN yum -y check-update || true && \ libzstd-devel && \ yum clean all -# Make GCC7, Python 3.5 and Maven 3.3 Software Collections available by default -# during build and runtime of this container +# Make Clang, Python 3.6 and Maven 3.3 Software Collections available during following build steps SHELL [ "/usr/bin/scl", "enable", "llvm-toolset-7.0", "rh-python36", "rh-maven35" ] # Install minimum required cmake version diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh index 7b83baa1ad5b..c36f306e8b6f 100755 --- a/tools/dependencies/openblas.sh +++ b/tools/dependencies/openblas.sh @@ -46,4 +46,11 @@ if [[ (! -e $DEPS_PATH/lib/libopenblas.a) ]]; then rm $DEPS_PATH/lib/libopenblas*.so popd + + # Makefile build declares -llapack even though libopenblas provides lapack + # symbols. Make sure -llapack doesn't cause any harm. + if [[ -z "$CMAKE_STATICBUILD" ]]; then + ln -s libopenblas.a $DEPS_PATH/lib/libcblas.a + ln -s libopenblas.a $DEPS_PATH/lib/liblapack.a + fi fi diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh index 56707261ecfa..9574cb6f1565 100755 --- a/tools/dependencies/opencv.sh +++ b/tools/dependencies/opencv.sh @@ -20,7 +20,7 @@ # This script builds the static library of opencv that can be used as dependency of mxnet. # It expects openblas, libjpeg, libpng, libtiff, eigen, etc., to be in $DEPS_PATH. set -ex -OPENCV_VERSION=3.4.2 +OPENCV_VERSION=3.4.8 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" if [[ $PLATFORM == 'linux' ]]; then OPENCV_LAPACK_OPTIONS=" \ diff --git a/tools/staticbuild/build.sh b/tools/staticbuild/build.sh index 786f93425a92..e57e3272d44f 100755 --- a/tools/staticbuild/build.sh +++ b/tools/staticbuild/build.sh @@ -48,7 +48,7 @@ else fi export MAKE="make $ADD_MAKE_FLAG" -if [[ $VARIANT == cu* ]]; then +if [[ $VARIANT == "cu"* ]]; then export CC="gcc" export CXX="g++" export CFLAGS="-fPIC -mno-avx" From dd47324fd5a9ef0cd460e2a044161f9d2239d276 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Wed, 10 Jun 2020 23:51:27 +0000 Subject: [PATCH 9/9] Keep OpenCV version at 3.4.2 Some release between 3.4.3 and 3.4.8 introduces a bug in OpenCV cmake configuration related to EIGEN handling, causing error in MXNet compilation. It may be fixed in upcoming OpenCV 3.4.11. --- tools/dependencies/opencv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh index 9574cb6f1565..56707261ecfa 100755 --- a/tools/dependencies/opencv.sh +++ b/tools/dependencies/opencv.sh @@ -20,7 +20,7 @@ # This script builds the static library of opencv that can be used as dependency of mxnet. # It expects openblas, libjpeg, libpng, libtiff, eigen, etc., to be in $DEPS_PATH. set -ex -OPENCV_VERSION=3.4.8 +OPENCV_VERSION=3.4.2 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" if [[ $PLATFORM == 'linux' ]]; then OPENCV_LAPACK_OPTIONS=" \