Skip to content

Commit

Permalink
fix dynamic_loader and some demo CMakeLists.txt
Browse files Browse the repository at this point in the history
test=develop
  • Loading branch information
luotao1 committed Mar 30, 2020
1 parent 0ebefb7 commit 3e516ee
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions paddle/fluid/inference/api/demo_ci/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ if(WITH_MKL)
set(MATH_LIB_PATH "${PADDLE_LIB_THIRD_PARTY_PATH}mklml")
include_directories("${MATH_LIB_PATH}/include")
if(WIN32)
set(MATH_LIB ${MATH_LIB_PATH}/lib/mklml${CMAKE_STATIC_LIBRARY_SUFFIX}
${MATH_LIB_PATH}/lib/libiomp5md${CMAKE_STATIC_LIBRARY_SUFFIX})
set(MATH_LIB ${MATH_LIB_PATH}/lib/mklml${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(MATH_LIB ${MATH_LIB_PATH}/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX}
${MATH_LIB_PATH}/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MATH_LIB ${MATH_LIB_PATH}/lib/libmklml_gnu${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(MKLDNN_PATH "${PADDLE_LIB_THIRD_PARTY_PATH}mkldnn")
if(EXISTS ${MKLDNN_PATH})
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/platform/dynload/dynamic_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DEFINE_string(
tensorrt_dir, "",
"Specify path for loading tensorrt library, such as libnvinfer.so.");

DEFINE_string(mklml_dir, "", "Specify path for loading libmklml_intel.so.");
DEFINE_string(mklml_dir, "", "Specify path for loading libmklml_gnu.so.");

DEFINE_string(op_dir, "", "Specify path for loading user-defined op library.");

Expand Down Expand Up @@ -274,11 +274,11 @@ void* GetTensorRtDsoHandle() {

void* GetMKLMLDsoHandle() {
#if defined(__APPLE__) || defined(__OSX__)
return GetDsoHandleFromSearchPath(FLAGS_mklml_dir, "libmklml_intel.dylib");
return GetDsoHandleFromSearchPath(FLAGS_mklml_dir, "libmklml_gnu.dylib");
#elif defined(_WIN32)
return GetDsoHandleFromSearchPath(FLAGS_mklml_dir, "mklml.dll");
#else
return GetDsoHandleFromSearchPath(FLAGS_mklml_dir, "libmklml_intel.so");
return GetDsoHandleFromSearchPath(FLAGS_mklml_dir, "libmklml_gnu.so");
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/train/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(WITH_MKL)
if(WIN32)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib)
else(WIN32)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel.so)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_gnu.so)
endif(WIN32)
else()
if(APPLE)
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/train/imdb_demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if(WITH_MKL)
if(WIN32)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/mklml.lib)
else(WIN32)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_intel.so)
set(MATH_LIB ${PADDLE_LIB}/third_party/install/mklml/lib/libmklml_gnu.so)
endif(WIN32)
else()
if(APPLE)
Expand Down
4 changes: 2 additions & 2 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if '${TENSORRT_FOUND}' == 'ON' and os.name == 'nt':

if '${WITH_MKL}' == 'ON':
shutil.copy('${MKLML_SHARED_LIB}', libs_path)
package_data['paddle.libs']+=[('libmklml_intel' if os.name != 'nt' else 'mklml') + ext_name, ('libiomp5' if os.name != 'nt' else 'libiomp5md') + ext_name]
package_data['paddle.libs']+=[('libmklml_gnu' if os.name != 'nt' else 'mklml') + ext_name, ('libiomp5' if os.name != 'nt' else 'libiomp5md') + ext_name]
# mklml has dependency to vs runtime library
if os.name == 'nt':
shutil.copy('${MKLML_SHARED_LIB_DEPS}', libs_path)
Expand All @@ -207,7 +207,7 @@ if '${WITH_MKLDNN}' == 'ON':
#
# change rpath of libdnnl.so.1, add $ORIGIN/ to it.
# The reason is that all thirdparty libraries in the same directory,
# thus, libdnnl.so.1 will find libmklml_intel.so and libiomp5.so.
# thus, libdnnl.so.1 will find libmklml_gnu.so.
command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}"
if os.system(command) != 0:
raise Exception("patch libdnnl.so failed, command: %s" % command)
Expand Down

0 comments on commit 3e516ee

Please sign in to comment.