-
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
use -rpath to fix libmklml_intel.so not found #11806
Conversation
@@ -0,0 +1,15 @@ | |||
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved |
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.
为什么要加这个文件呢?我看numpy的lib下面只有so.
$ pwd
xxx/python2.7/site-packages/numpy/.libs
$ ll
-rwxrwxr-x 1 tangjian tangjian 1023960 Jun 15 01:01 libgfortran-ed201abd.so.3.0.0
-rwxrwxr-x 1 tangjian tangjian 38513408 Jun 15 01:01 libopenblasp-r0-39a31c03.2.18.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.
一开始如果没有__init__.py的话,whl打包的时候,会找不到这个目录。不过可以尝试在打包后删除这个文件。
python/setup.py.in
Outdated
# The reason is that libwarpctc.so, libiomp5.so etc are in paddle.libs, and | ||
# core.so is in paddle.fluid, thus paddle/fluid/../libs will pointer to above libraries. | ||
# This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213 | ||
os.environ['core_rpath']=str(os.popen("patchelf --print-rpath \ |
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.
为什么要用environ?直接存一个string可以吗?
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.
存一个string的写法一直没有搞定,所以换成environ了。
python/setup.py.in
Outdated
# This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213 | ||
os.environ['core_rpath']=str(os.popen("patchelf --print-rpath \ | ||
${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so").read().strip('\n')) | ||
os.environ['core_rpath']=os.environ['core_rpath']+":'$ORIGIN/../libs/'" |
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.
其实我觉得是不是别的路径都不需要,只要ORIGIN那个就好了,因为他的路径都是编译时就有的。安装之后很大可能也用不到。
Library runpath: [/home/tangjian/.jumbo/opt/gcc48/lib64:/home/tangjian/.jumbo/lib:$ORIGIN/../libs/]
ldd core.so
libiomp5.so => /usr/local/lib/python2.7/dist-packages/paddle/fluid/./../libs/libiomp5.so (0x00007ff7b16c6000)
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 rpath is successful: https://paddleci.ngrok.io/viewLog.html?buildId=982&buildTypeId=Paddle_PrCi&tab=buildLog&_focus=10506
The ldd is successful as well: https://paddleci.ngrok.io/viewLog.html?buildId=982&buildTypeId=Paddle_PrCi&tab=buildLog&_focus=10534
But the unittest fails: https://paddleci.ngrok.io/viewLog.html?buildId=982&buildTypeId=Paddle_PrCi&tab=buildLog&_focus=10593
The unittest is in Paddle/paddle/scripts/paddle_build.sh Lines 315 to 326 in 94e3cff
|
I reproduce the error, the reason is that when
|
# The reason is that all thirdparty libraries in the same directory, | ||
# thus, libmkldnn.so.0 will find libmklml_intel.so and libiomp5.so. | ||
command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}" | ||
os.system(command) |
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.
May need to check the return value?
# core.so is in paddle.fluid, thus paddle/fluid/../libs will pointer to above libraries. | ||
# This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213 | ||
command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so" | ||
os.system(command) |
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.
Same as above, need some checks.
fails at https://travis-ci.org/PaddlePaddle/Paddle/jobs/400331461#L2880
The reason is that @typhoonzero Could I add the check next PR? |
@typhoonzero I remove the check this PR, and after |
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++
comments by @ @jianhang-liu 一直觉得用patchelf手动修改RPATH不漂亮,但之前修改CMake文件一直未能成功改变RPATH。做了点调查,现在清楚为什么了。 先说结论:
如果是正常安装(而非打包到.whl里),则正确的修改应如下:
以上修改可保证在build tree或安装位置都能通过RPATH找到库,并且在把整个安装目录移到其它位置时仍能通过RPATH找到库。 有兴趣的话,可参见这篇文档,写的很透彻。 |
|
rpath的修改应该是在这个版本之后了。pypi不支持覆盖所以得在下一个版本发布了。或者发布一个bug fix 版本0.14.1 |
* use -rpath to fix libmklml_intel.so not found * only remain $ORIGIN/../libs in rpath of core.so * test * test * add rpath of libmkldnn.so.0 * check return value of os.system * remove check return value of patchelf
fix #11452
fix #9034
fix http://www.paddlepaddle.org/docs/develop/documentation/zh/faq/build_and_install/index_cn.html#permalink-15-10-pip-paddlepaddle-import-paddle-fluid-libmkldnn-so-libmklml_intel-so
Thanks @jianhang-liu provide helps : develop...jianhang-liu:relative_loading_path