-
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
add MKL for fluid static and shared library #8887
Conversation
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.
这个示例里面,我认为链接libpaddle_fluid.so
的时候也是需要链接libmklml_intel.so
的,我后面会测试一下。
======Update======
我本地测试过了,fluid_inference_example
项目make
时会出如下错误:
/home/liuyiqun01/.jumbo/opt/gcc48/bin/g++ CMakeFiles/example.dir/example.cc.o -o example -rdynamic /home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/dist/paddle/fluid/inference/libpaddle_fluid.so /home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/dist/third_party/install/gflags/lib/libgflags.a -lrt -ldl -lpthread -Wl,-rpath,/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/dist/paddle/fluid/inference
/home/liuyiqun01/.jumbo/opt/binutils/bin/ld: warning: libiomp5.so, needed by /home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so, not found (try using -rpath or -rpath-link)
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so: undefined reference to `__kmpc_atomic_float4_max@VERSION'
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so: undefined reference to `__kmpc_master@VERSION'
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so: undefined reference to `__kmpc_single@VERSION'
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so: undefined reference to `__kmpc_end_serialized_parallel@VERSION'
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/third_party/install/mklml/lib/libmklml_intel.so: undefined reference to `omp_in_parallel@VERSION'
...
需要链接mkl_intel
和iomp5
两个动态库。
cmake/inference_lib.cmake
Outdated
copy(mklml_lib | ||
SRCS ${MKLML_LIB_DIR} ${MKLML_INC_DIR} | ||
DSTS ${dst_dir} ${dst_dir} | ||
) |
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.
- 这里应该加
if(WITH_MKLML)
判断? - ~~如果链接了
mklml
库,貌似还需要链接iomp
库?~~看错了,已经全部拷贝过去了。另外问一句,libmklml_gnu.so
是不是用不上?
Lines 118 to 120 in 4f9c996
if(WITH_MKLML AND MKLML_LIB_DIR AND MKLML_IOMP_LIB) target_link_libraries(${TARGET_NAME} "-L${MKLML_LIB_DIR} -liomp5 -Wl,--as-needed") endif()
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.
这里应该加if(WITH_MKLML)判断
不需要加,if(CBLAS_FOUND)时能正确拷贝MKLML相关的库:
https://paddleci.ngrok.io/viewLog.html?buildId=30302&buildTypeId=Paddle_PrCi&tab=buildLog&_focus=13970#_state=71
libmklml_gnu.so是不是用不上
对的,这个库用不上。所以需要把这个库给去掉么?
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.
需要加if(WITH_MKLML)
判断的。如果用户cmake设置WITH_MKL=OFF
并且设置了OPEBLAS_ROOT
,这里不加判断应该会出错。
所以需要把这个库给去掉么?
我觉得可以去掉,至少make inference_lib_dist
的时候不要拷贝过去吧。
@@ -46,7 +46,7 @@ INCLUDE_DIRECTORIES(${MKLML_INC_DIR}) | |||
FILE(WRITE ${MKLML_DOWNLOAD_DIR}/CMakeLists.txt | |||
"PROJECT(MKLML)\n" | |||
"cmake_minimum_required(VERSION 3.0)\n" | |||
"install(DIRECTORY ${MKLML_VER}\n" | |||
"install(DIRECTORY ${MKLML_VER}/include ${MKLML_VER}/lib \n" | |||
" DESTINATION ${MKLML_DST_DIR})\n") |
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.
mklml
的依赖是不是不太对?我把third_party
和third_party/install
下面的mklml
删掉了之后,make -j12
出现了如下编译错误:
[ 13%] Building NVCC (Device) object paddle/fluid/operators/math/CMakeFiles/selected_rows_functor.dir/selected_rows_functor_generated_selected_rows_functor.cu.o
In file included from /home/liuyiqun01/PaddlePaddle/Paddle/paddle/fluid/operators/math/selected_rows_functor.cu:17:0:
/home/liuyiqun01/PaddlePaddle/Paddle/paddle/fluid/operators/math/math_function.h:17:23: fatal error: mkl_cblas.h: No such file or directory
#include <mkl_cblas.h>
^
compilation terminated.
CMake Error at selected_rows_functor_generated_selected_rows_functor.cu.o.cmake:202 (message):
Error generating
/home/liuyiqun01/PaddlePaddle/Paddle/build_paddle/build/paddle/fluid/operators/math/CMakeFiles/selected_rows_functor.dir//./selected_rows_functor_generated_selected_rows_functor.cu.o
make[2]: *** [paddle/fluid/operators/math/CMakeFiles/selected_rows_functor.dir/selected_rows_functor_generated_selected_rows_functor.cu.o] Error 1
make[1]: *** [paddle/fluid/operators/math/CMakeFiles/selected_rows_functor.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
======Update======
develop分支下载hang住了,但似乎没出现这个错误。
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.
mklml的依赖是不是不太对
依赖是对的,teamcity上的编译能正常通过。
develop分支下载hang住了
是在厂内测试机上下载mklml的时候hang住了么?厂内测试机的下载会受到网络或SSL因素影响,导致下载失败,可以参考这里进行手动安装。
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.
手动安装就没法正确测试这个依赖了。。。依赖从直观上来看觉得没什么问题,但是想不通为啥会遇到这个错误。。。
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.
手动安装的时候,只是在third_party/mklml
中手动下载和解压了mklml.tgz这个包,后面install到third_party/install/mklml
的时候还需要使用make
命令,所以是能正确测试依赖的。
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.
这个其实不一定,因为没有了下载这个过程,解压的过程很快,很可能因为这个任务很快就完成了,而其他地方即使没有正确地依赖,也不会出错。不过因为cmake我看不出来问题,develop分支也没有遇到这个错误,可能是解决了吧。
|
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.
LGTM
@@ -46,7 +46,7 @@ INCLUDE_DIRECTORIES(${MKLML_INC_DIR}) | |||
FILE(WRITE ${MKLML_DOWNLOAD_DIR}/CMakeLists.txt | |||
"PROJECT(MKLML)\n" | |||
"cmake_minimum_required(VERSION 3.0)\n" | |||
"install(DIRECTORY ${MKLML_VER}\n" | |||
"install(DIRECTORY ${MKLML_VER}/include ${MKLML_VER}/lib \n" | |||
" DESTINATION ${MKLML_DST_DIR})\n") |
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.
这个其实不一定,因为没有了下载这个过程,解压的过程很快,很可能因为这个任务很快就完成了,而其他地方即使没有正确地依赖,也不会出错。不过因为cmake我看不出来问题,develop分支也没有遇到这个错误,可能是解决了吧。
PADDLE_USE_ATLAS
which is forgot by remove ATLAS library #6530