-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable Intel MKLDNN library and Intel MKL small package #2940
Changes from 1 commit
89a4158
f490d94
1601c34
577bb4e
f6dd8ae
a7e23a4
19ec08f
2fd43fc
75f6676
1cf5057
95ce961
19c465b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,6 @@ SET(MKLDNN_SOURCES_DIR ${THIRD_PARTY_PATH}/mkldnn) | |
SET(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn) | ||
SET(MKLDNN_INCLUDE_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE) | ||
|
||
# The following magic numbers should be updated regularly to keep latest version | ||
SET(MKLDNN_TAG "v0.9") | ||
SET(MKLDNN_MKL_VER "mklml_lnx_2018.0.20170425") | ||
|
||
IF(WIN32) | ||
MESSAGE(WARNING "It is not supported compiling with mkldnn in windows Paddle yet." | ||
"Force WITH_MKLDNN=OFF") | ||
|
@@ -42,37 +38,29 @@ ENDIF(WIN32) | |
|
||
INCLUDE_DIRECTORIES(${MKLDNN_INCLUDE_DIR}) | ||
|
||
SET(MKLDNN_CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
SET(MKLDNN_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
IF(${CBLAS_PROVIDER} STREQUAL "MKL_LITE") | ||
SET(MKLDNN_DEPENDS ${MKL_LITE_PROJECT}) | ||
SET(MKLDNN_MKLROOT ${MKL_LITE_ROOT}) | ||
SET(MKLDNN_IOMP_DIR ${MKL_LITE_LIB_DIR}) | ||
ENDIF() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will not bother by mkl_lite if |
||
|
||
ExternalProject_Add( | ||
${MKLDNN_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
GIT_REPOSITORY "https://github.com/01org/mkl-dnn.git" | ||
GIT_TAG "${MKLDNN_TAG}" | ||
PREFIX ${MKLDNN_SOURCES_DIR} | ||
PATCH_COMMAND cd <SOURCE_DIR>/scripts && ./prepare_mkl.sh | ||
UPDATE_COMMAND "" | ||
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | ||
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${MKLDNN_CMAKE_CXX_FLAGS} | ||
CMAKE_ARGS -DCMAKE_C_FLAGS=${MKLDNN_CMAKE_C_FLAGS} | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} | ||
CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=${MKLDNN_INSTALL_DIR}/lib | ||
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release | ||
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR} | ||
-DCMAKE_INSTALL_LIBDIR:PATH=${MKLDNN_INSTALL_DIR}/lib | ||
-DCMAKE_BUILD_TYPE:STRING=Release | ||
DEPENDS ${MKLDNN_DEPENDS} | ||
GIT_REPOSITORY "https://github.com/01org/mkl-dnn.git" | ||
GIT_TAG "v0.9" | ||
PREFIX ${MKLDNN_SOURCES_DIR} | ||
CONFIGURE_COMMAND mkdir -p <SOURCE_DIR>/build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you specify For instance ExternalProject_Add(
zlib
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.8"
PREFIX ${ZLIB_SOURCES_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
CMAKE_ARGS -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZLIB_INSTALL_DIR}
CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON
CMAKE_ARGS -DCMAKE_MACOSX_RPATH=ON
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ZLIB_INSTALL_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=Release
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last time used the way you prefer, but since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with @gangliao , the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tensor-tang it's ok to use the way you like, as long as Travis CI and TeamCity can successfully build. Thanks for your work. |
||
BUILD_COMMAND cd <SOURCE_DIR>/build | ||
&& cmake .. -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} -DMKLROOT=${MKLDNN_MKLROOT} | ||
&& make all -j${CPU_CORES} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not clear with your point about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh... I see, what is the total cores number in you system? more than 12 right? |
||
INSTALL_COMMAND cd <SOURCE_DIR>/build && make install | ||
UPDATE_COMMAND "" | ||
) | ||
|
||
SET(MKL_LITE_DIR ${MKLDNN_SOURCES_DIR}/src/${MKLDNN_PROJECT}/external/${MKLDNN_MKL_VER}) | ||
SET(MKL_LITE_INC_DIR ${MKL_LITE_DIR}/include) | ||
SET(MKL_LITE_LIB ${MKL_LITE_DIR}/lib/libmklml_intel.so) | ||
SET(MKL_LITE_LIB_IOMP ${MKL_LITE_DIR}/lib/libiomp5.so) | ||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKL_LITE_DIR}/lib") | ||
|
||
ADD_LIBRARY(mkldnn STATIC IMPORTED GLOBAL) | ||
SET_PROPERTY(TARGET mkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIBRARY}) | ||
ADD_DEPENDENCIES(mkldnn ${MKLDNN_PROJECT}) | ||
|
||
MESSAGE(STATUS "Mkldnn library: ${MKLDNN_LIBRARY}") | ||
LIST(APPEND external_project_dependencies mkldnn) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2017 PaddlePaddle Authors. All Rights Reserve. | ||
# | ||
# Licensed 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. | ||
|
||
IF(NOT ${WITH_MKL_LITE}) | ||
return() | ||
ENDIF(NOT ${WITH_MKL_LITE}) | ||
|
||
INCLUDE(ExternalProject) | ||
|
||
SET(MKL_LITE_PROJECT "extern_mkllite") | ||
SET(MKL_LITE_VER "mklml_lnx_2018.0.20170425") | ||
SET(MKL_LITE_URL "https://github.com/01org/mkl-dnn/releases/download/v0.9/${MKL_LITE_VER}.tgz") | ||
SET(MKL_LITE_DOWNLOAD_DIR ${THIRD_PARTY_PATH}/mkllite) | ||
|
||
SET(MKL_LITE_ROOT ${MKL_LITE_DOWNLOAD_DIR}/${MKL_LITE_VER}) | ||
SET(MKL_LITE_INC_DIR ${MKL_LITE_ROOT}/include) | ||
SET(MKL_LITE_LIB_DIR ${MKL_LITE_ROOT}/lib) | ||
SET(MKL_LITE_LIB ${MKL_LITE_LIB_DIR}/libmklml_intel.so) | ||
SET(MKL_LITE_IOMP_LIB ${MKL_LITE_LIB_DIR}/libiomp5.so) | ||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKL_LITE_ROOT}/lib") | ||
|
||
INCLUDE_DIRECTORIES(${MKL_LITE_INC_DIR}) | ||
|
||
ExternalProject_Add( | ||
${MKL_LITE_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
PREFIX ${MKL_LITE_DOWNLOAD_DIR} | ||
DOWNLOAD_DIR ${MKL_LITE_DOWNLOAD_DIR} | ||
DOWNLOAD_COMMAND wget --no-check-certificate ${MKL_LITE_URL} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For instance, ExternalProject_Add(
zlib
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.2.8"
PREFIX ${ZLIB_SOURCES_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
CMAKE_ARGS -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZLIB_INSTALL_DIR}
CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON
CMAKE_ARGS -DCMAKE_MACOSX_RPATH=ON
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ZLIB_INSTALL_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=Release
) hard-code might not works in our internal system There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a git, just a tar package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, I found swig used this way too
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gangliao I tried to use the following command instead and met some error. It is the same as #2666, because the downloading source is a
However, @tensor-tang the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tensor-tang |
||
&& tar -xzf ${MKL_LITE_DOWNLOAD_DIR}/${MKL_LITE_VER}.tgz | ||
DOWNLOAD_NO_PROGRESS 1 | ||
UPDATE_COMMAND "" | ||
PATCH_COMMAND "" | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "" | ||
) | ||
|
||
IF (${CMAKE_VERSION} VERSION_LESS "3.3.0") | ||
SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/mkllite_dummy.c) | ||
FILE(WRITE ${dummyfile} "const char * dummy_mkllite = \"${dummyfile}\";") | ||
ADD_LIBRARY(mkllite STATIC ${dummyfile}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
ELSE() | ||
ADD_LIBRARY(mkllite INTERFACE) | ||
ENDIF() | ||
|
||
ADD_DEPENDENCIES(mkllite ${MKL_LITE_PROJECT}) | ||
|
||
LIST(APPEND external_project_dependencies mkllite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When compiling Paddle with
make -j12
, I met the following error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did you set
make -j12
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same error, but I use
make
. I can't find liomp5 too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give the details error message? @luotao1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tensor-tang I think we need use
make -j12
to speed up the building process.