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

Commit f9d90c9

Browse files
authored
[BUGFIX] Ubuntu 20.04: support for in-distro Intel MKL libraries (#19766)
* Improve MxNet framework building on Ubuntu 20.04 Ubuntu 20.04: - add support for intel-mkl distribution version; - use FindBLAS cmake function to look for the intel-mkl; - add FindBLAS.cmake file upstream version (due to Intel10_64_dyn & --start-group/--end-gropup options support) - remove FindMKL.cmake; - preserve Ubuntu 18.04 images for TensorRT pipeline; - preserve MKL libraries linking support on non-Ubuntu 20.04 OSes (w/o FindMKL.cmake file). * Temporarily use numpy < 1.20 on CI
1 parent 49edbfc commit f9d90c9

7 files changed

Lines changed: 1099 additions & 175 deletions

File tree

ci/docker/Dockerfile.build.ubuntu

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ FROM $BASE_IMAGE AS base
3333

3434
WORKDIR /work/deps
3535

36+
SHELL ["/bin/bash", "-c"]
3637
RUN export DEBIAN_FRONTEND=noninteractive && \
38+
export OS_RELEASE="$(cat /etc/os-release)" && \
3739
apt-get update && \
3840
apt-get install -y wget software-properties-common && \
39-
wget -qO - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB | apt-key add - && \
40-
apt-add-repository "deb https://apt.repos.intel.com/mkl all main" && \
41+
if [[ ${OS_RELEASE} == *"Bionic"* ]]; then \
42+
wget -qO - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB | apt-key add -; \
43+
apt-add-repository "deb https://apt.repos.intel.com/mkl all main"; \
44+
INTEL_MKL="-2020.0-088"; \
45+
fi && \
4146
apt-get update && \
4247
apt-get install -y \
4348
## Utilities
@@ -58,7 +63,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
5863
g++ \
5964
g++-7 \
6065
g++-8 \
61-
intel-mkl-2020.0-088 \
66+
intel-mkl${INTEL_MKL} \
6267
libomp-dev \
6368
## Dependencies
6469
libgomp1 \

ci/docker/install/requirements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# the whole docker cache for the image
2020

2121
# Required dependencies
22-
numpy>=1.17
22+
numpy<1.20.0
2323
requests>=2.20.0,<3
2424
graphviz<0.9.0,>=0.8.1
2525
contextvars;python_version<"3.7"

cmake/ChooseBlas.cmake

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,49 @@ set(FORTRAN_DIR \\\"\$\{CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES\}\\\")
121121
endif()
122122
endif()
123123
elseif(BLAS STREQUAL "MKL" OR BLAS STREQUAL "mkl")
124-
if (USE_INT64_TENSOR_SIZE)
125-
set(MKL_USE_ILP64 ON CACHE BOOL "enable using ILP64 in MKL" FORCE)
124+
# ---[ Root folders
125+
set(INTEL_HOME_ROOT "$ENV{HOME}/intel" CACHE PATH "Folder contains user-installed intel libs")
126+
set(INTEL_OPT_ROOT "/opt/intel" CACHE PATH "Folder contains root-installed intel libs")
127+
128+
# ---[ MKL Options
129+
if(UNIX)
130+
# Single dynamic library interface leads to conflicts between intel omp and llvm omp
131+
# https://github.com/apache/incubator-mxnet/issues/17641
132+
option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" OFF)
126133
else()
127-
if(MKL_USE_ILP64)
128-
message(FATAL_ERROR "MKL_USE_ILP64 cannot be set without USE_INT64_TENSOR_SIZE; "
129-
"Please set USE_INT64_TENSOR_SIZE instead of MKL_USE_ILP64.")
134+
option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON)
135+
endif()
136+
cmake_dependent_option(BLA_STATIC "Use static libraries" ON "NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY" OFF)
137+
cmake_dependent_option(MKL_MULTI_THREADED "Use multi-threading" ON "NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY" OFF)
138+
139+
if(MKL_USE_SINGLE_DYNAMIC_LIBRARY)
140+
set(BLA_VENDOR Intel10_64_dyn)
141+
add_definitions(-DMKL_USE_SINGLE_DYNAMIC_LIBRARY=1)
142+
else()
143+
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
144+
set(BLA_VENDOR Intel10_32)
145+
else()
146+
if(MKL_MULTI_THREADED)
147+
if(USE_INT64_TENSOR_SIZE)
148+
set(BLA_VENDOR Intel10_64ilp)
149+
else()
150+
set(BLA_VENDOR Intel10_64lp)
151+
endif()
152+
else()
153+
if(USE_INT64_TENSOR_SIZE)
154+
set(BLA_VENDOR Intel10_64ilp_seq)
155+
else()
156+
set(BLA_VENDOR Intel10_64lp_seq)
157+
endif()
158+
endif()
130159
endif()
131160
endif()
132-
find_package(MKL REQUIRED)
161+
# Setting up BLAS_mkl_MKLROOT for non-Ubuntu 20.04 OSes
162+
find_path(BLAS_mkl_MKLROOT mkl PATHS $ENV{MKLROOT} ${INTEL_HOME_ROOT} ${INTEL_OPT_ROOT})
163+
find_package(BLAS)
164+
find_path(MKL_INCLUDE_DIR mkl.h HINTS ${INTEL_HOME_ROOT}/mkl ${INTEL_OPT_ROOT}/mkl PATHS ENV MKLROOT PATH_SUFFIXES include mkl REQUIRED)
133165
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
134-
list(APPEND mshadow_LINKER_LIBS ${MKL_LIBRARIES})
166+
list(APPEND mshadow_LINKER_LIBS ${BLAS_LIBRARIES})
135167
add_definitions(-DMSHADOW_USE_CBLAS=0)
136168
add_definitions(-DMSHADOW_USE_MKL=1)
137169
add_definitions(-DMXNET_USE_BLAS_MKL=1)

cmake/Modules/FindMKL.cmake

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)