Skip to content

Commit

Permalink
CI: Switch to cmake builds for majority of tests (apache#17645)
Browse files Browse the repository at this point in the history
The following Makefile based builds are preserved
1) staticbuild scripts
2) Docs builds. Language binding specific build logic requires further changes
3) Jetson build. Jetpack 3.3 toolchain based on Cuda 9.0 causes 'Internal
   Compiler Error (codegen): "there was an error in verifying the lgenfe
   output!"' errors with cmake. This seems to be a known issue in Cuda 9.0 and
   we need to update Jetpack toolchain to work around it.
4) MKL builds. Waiting for fix of apache#17641

All Makefile based builds are marked with a "Makefile" postfix in the title.

Improvements to CMake build
- Enable -Werror for RelWithDebugInfo build in analogy to "make DEV=1" build
- Add USE_LIBJPEG_TURBO to CMake build
- Improve finding Python 3 executable

Changes to CI setup
- Install protobuf and zmq where missing
- Install up-to-date CMake on Centos 7
- Don't use RelWithDebInfo on Android builds, as gcc 4.9 throws
  -Wdelete-non-virtual-dtor

Code changes
- Disable warnings introduced by GCC7 at via #pragma GCC diagnostic
  • Loading branch information
leezu authored and anirudh2290 committed May 29, 2020
1 parent ba4afe3 commit fa6e45e
Show file tree
Hide file tree
Showing 26 changed files with 433 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/os_x_staticbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: actions/checkout@v2
- name: Install Dependencies
run: |
brew install nasm automake ninja libtool
brew install nasm automake ninja libtool cmake pkgconfig protobuf
- name: Build project
run: |
git --version
Expand Down
9 changes: 8 additions & 1 deletion 3rdparty/mshadow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ add_library(mshadow INTERFACE)
file(GLOB_RECURSE MSHADOWSOURCE "mshadow/*.h")
target_include_directories(mshadow INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
target_sources(mshadow INTERFACE ${MSHADOWSOURCE})
if(UNIX)
target_compile_options(mshadow INTERFACE
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-parameter>"
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unknown-pragmas>"
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-local-typedefs>")
endif()

if(USE_CUDA)
enable_language(CUDA)
Expand Down Expand Up @@ -67,7 +73,8 @@ else()
endif()

set(mshadow_LINT_DIRS mshadow mshadow-ps)
find_package(Python3)
add_custom_target(mshadow_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLINT_DIRS=${mshadow_LINT_DIRS}
-DPYTHON_EXECUTABLE=${Python3_EXECUTABLE} -DLINT_DIRS=${mshadow_LINT_DIRS}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DPROJECT_NAME=mshadow
-P ${PROJECT_SOURCE_DIR}/../dmlc-core/cmake/lint.cmake)
9 changes: 5 additions & 4 deletions 3rdparty/mshadow/mshadow/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
#define NOMINMAX
#endif
#endif
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <limits>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -839,7 +840,7 @@ MSHADOW_XINLINE bool MaxValue<bool>(void) {
/*! \brief maximum value of uint32_t */
template<>
MSHADOW_XINLINE uint32_t MaxValue<uint32_t>(void) {
return -1;
return std::numeric_limits<uint32_t>::max();
}

/*!
Expand Down
40 changes: 25 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ else()
endif()
option(USE_GPERFTOOLS "Build with GPerfTools support" OFF)
option(USE_JEMALLOC "Build with Jemalloc support" OFF)
option(USE_LIBJPEG_TURBO "Use libjpeg-turbo" OFF)
option(USE_DIST_KVSTORE "Build with DIST_KVSTORE support" OFF)
option(USE_PLUGINS_WARPCTC "Use WARPCTC Plugins" OFF)
option(USE_PLUGIN_CAFFE "Use Caffe Plugin" OFF)
Expand Down Expand Up @@ -381,6 +382,16 @@ if(USE_JEMALLOC)
endif()
endif()

if(USE_LIBJPEG_TURBO)
find_package(PkgConfig REQUIRED)
pkg_search_module(TURBOJPEG REQUIRED libturbojpeg)
include_directories(SYSTEM ${TURBOJPEG_INCLUDE_DIRS})
list(APPEND mxnet_LINKER_LIBS ${TURBOJPEG_LINK_LIBRARIES})
add_definitions(-DMXNET_USE_LIBJPEG_TURBO=1)
else()
add_definitions(-DMXNET_USE_LIBJPEG_TURBO=0)
endif()

# ---[ OpenCV
if(USE_OPENCV)
find_package(OpenCV COMPONENTS core highgui imgproc imgcodecs)
Expand Down Expand Up @@ -661,7 +672,7 @@ add_subdirectory("3rdparty/mshadow")

set(MXNET_INSTALL_TARGETS mxnet)
if(UNIX)
string(APPEND CMAKE_CUDA_FLAGS "${CUDA_ARCH_FLAGS_SPACES}")
string(APPEND CMAKE_CUDA_FLAGS " ${CUDA_ARCH_FLAGS_SPACES}")
# Create dummy file since we want an empty shared library before linking
set(DUMMY_SOURCE ${CMAKE_BINARY_DIR}/dummy.c)
file(WRITE ${DUMMY_SOURCE} "")
Expand All @@ -673,6 +684,15 @@ if(UNIX)
target_link_libraries(mxnet PRIVATE mxnet_static)
target_link_libraries(mxnet_static PUBLIC ${CMAKE_DL_LIBS})
set_target_properties(mxnet_static PROPERTIES OUTPUT_NAME mxnet)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
target_compile_options(mxnet_static PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Werror>")
# Ignore erroneous compiler warnings:
# 1) variables used in '#pragma omp parallel' are considered unused
target_compile_options(mxnet_static PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-error=unused-variable>")
if(USE_CUDA)
string(APPEND CMAKE_CUDA_FLAGS " -Werror cross-execution-space-call")
endif()
endif()
elseif(MSVC)
if(USE_CUDA)
if(MSVC)
Expand Down Expand Up @@ -708,7 +728,7 @@ elseif(MSVC)
COMMAND gen_warp $<TARGET_FILE:mxnet_${mxnet_first_arch}> WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ DEPENDS $<TARGET_FILE:mxnet_${mxnet_first_arch}>)
else(USE_SPLIT_ARCH_DLL)
string(REPLACE ";" " " NVCC_FLAGS_ARCH "${NVCC_FLAGS_ARCH}")
set(CMAKE_CUDA_FLAGS "${CUDA_ARCH_FLAGS_SPACES}")
set(CMAKE_CUDA_FLAGS " ${CUDA_ARCH_FLAGS_SPACES}")
add_library(mxnet SHARED ${SOURCE})
target_link_libraries(mxnet PUBLIC mshadow)
target_compile_options(
Expand Down Expand Up @@ -778,14 +798,7 @@ endfunction()
if(USE_TVM_OP)
list(APPEND mxnet_LINKER_LIBS ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm/libtvm_runtime.so)
BuildTVMOP()
if(NOT Python3_EXECUTABLE)
find_package(PythonInterp 3 REQUIRED)
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Path to the python3 executable")
if(NOT Python3_EXECUTABLE)
message(FATAL_ERROR "No python3 interpreter found to build TVM operators")
endif()
endif()

find_package(Python3 REQUIRED)
set(TVM_OP_COMPILE_OPTIONS "-o${CMAKE_CURRENT_BINARY_DIR}" "--config" "${CMAKE_CURRENT_BINARY_DIR}/tvmop.conf" "-L" "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm")
if(USE_CUDA)
set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" "\"${CUDA_ARCH_FLAGS}\"")
Expand Down Expand Up @@ -904,13 +917,10 @@ endif()
add_subdirectory(tests)

# ---[ Linter target
if(MSVC)
find_package(PythonInterp)
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Path to the python executable")
endif()
find_package(Python3)
set(LINT_DIRS "include src plugin cpp-package tests")
set(EXCLUDE_PATH "src/operator/contrib/ctc_include")
add_custom_target(mxnet_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLINT_DIRS=${LINT_DIRS} -DPROJECT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DPROJECT_NAME=mxnet -DEXCLUDE_PATH=${EXCLUDE_PATH} -P ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/cmake/lint.cmake)
add_custom_target(mxnet_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DPYTHON_EXECUTABLE=${Python3_EXECUTABLE} -DLINT_DIRS=${LINT_DIRS} -DPROJECT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DPROJECT_NAME=mxnet -DEXCLUDE_PATH=${EXCLUDE_PATH} -P ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/cmake/lint.cmake)

if(BUILD_CYTHON_MODULES)
include(cmake/BuildCythonModules.cmake)
Expand Down
2 changes: 1 addition & 1 deletion R-package/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rcpplint:
3rdparty/dmlc-core/scripts/lint.py mxnet-rcpp ${LINT_LANG} R-package/src
./3rdparty/dmlc-core/scripts/lint.py mxnet-rcpp all R-package/src

rpkg:
mkdir -p R-package/inst/libs
Expand Down
15 changes: 14 additions & 1 deletion ci/docker/install/centos7_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ yum -y install epel-release
yum -y install git
yum -y install wget
yum -y install make
yum -y install cmake
yum -y install unzip
yum -y install ninja-build
yum -y install gcc-gfortran
yum -y install protobuf-compiler
yum -y install protobuf-devel
yum -y install zeromq-devel

# Centos 7 only provides ninja-build
ln -s /usr/bin/ninja-build /usr/bin/ninja

# CMake 3.13.2+ is required
mkdir /opt/cmake && cd /opt/cmake
wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
rm cmake-3.13.5-Linux-x86_64.sh
cmake --version
15 changes: 14 additions & 1 deletion ci/docker/install/centos7_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@ yum -y install atlas-devel # Provide clbas headerfiles
yum -y install openblas-devel
yum -y install lapack-devel
yum -y install opencv-devel
yum -y install protobuf-compiler
yum -y install protobuf-devel
yum -y install zeromq-devel
yum -y install openssl-devel
yum -y install gcc-c++-4.8.*
yum -y install make
yum -y install cmake
yum -y install wget
yum -y install unzip
yum -y install ninja-build

# Centos 7 only provides ninja-build
ln -s /usr/bin/ninja-build /usr/bin/ninja

# CMake 3.13.2+ is required
mkdir /opt/cmake && cd /opt/cmake
wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
rm cmake-3.13.5-Linux-x86_64.sh
cmake --version
2 changes: 2 additions & 0 deletions ci/docker/install/ubuntu_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ apt-get install -y \
zlib1g-dev \
libedit-dev \
libxml2-dev \
libprotobuf-dev \
protobuf-compiler \
ninja-build \
software-properties-common \
sudo \
Expand Down
Loading

0 comments on commit fa6e45e

Please sign in to comment.