-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d12a386
use -rpath to fix libmklml_intel.so not found
luotao1 3e4b0d7
only remain $ORIGIN/../libs in rpath of core.so
luotao1 ccda8e4
Merge branch 'develop' into mklml_rpath
luotao1 25a2b7c
test
luotao1 37ee566
Merge branch 'mklml_rpath' of https://github.com/luotao1/Paddle into …
luotao1 f0deb4c
test
luotao1 446377e
add rpath of libmkldnn.so.0
luotao1 31d6387
Merge branch 'develop' into mklml_rpath
luotao1 7604258
check return value of os.system
luotao1 83034c1
remove check return value of patchelf
luotao1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved | ||
# | ||
# 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. | ||
|
||
# used for setup.py.in to store the thirdparty shared libraries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from setuptools import setup, Distribution, Extension | ||
import subprocess | ||
import shutil | ||
import os | ||
class BinaryDistribution(Distribution): | ||
def has_ext_modules(foo): | ||
return True | ||
|
@@ -62,6 +64,7 @@ write_version_py(filename='@PADDLE_BINARY_DIR@/python/paddle/version.py') | |
|
||
|
||
packages=['paddle', | ||
'paddle.libs', | ||
'paddle.utils', | ||
'paddle.dataset', | ||
'paddle.reader', | ||
|
@@ -113,12 +116,33 @@ package_dir={ | |
} | ||
if '${WITH_FLUID_ONLY}'== 'OFF': | ||
package_dir['py_paddle']='${PADDLE_BINARY_DIR}/python/py_paddle' | ||
|
||
|
||
paddle_rt_lib_dir = 'lib' | ||
paddle_rt_libs = ['${WARPCTC_LIBRARIES}'] | ||
if '${MKL_SHARED_LIBS}'!= '': | ||
paddle_rt_libs += '${MKL_SHARED_LIBS}'.split(';') | ||
# put all thirdparty libraries in paddle.libs | ||
package_data['paddle.libs']=['libwarpctc.so'] | ||
libs_path='${PADDLE_BINARY_DIR}/python/paddle/libs' | ||
shutil.copy('${WARPCTC_LIBRARIES}', libs_path) | ||
if '${WITH_MKL}' == 'ON': | ||
shutil.copy('${MKLML_LIB}', libs_path) | ||
shutil.copy('${MKLML_IOMP_LIB}', libs_path) | ||
package_data['paddle.libs']+=['libmklml_intel.so','libiomp5.so'] | ||
if '${WITH_MKLDNN}' == 'ON': | ||
# change rpath of libmkldnn.so.0, add $ORIGIN/ to it. | ||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. May need to check the return value? |
||
package_data['paddle.libs']+=['libmkldnn.so.0'] | ||
shutil.copy('${MKLDNN_SHARED_LIB}', libs_path) | ||
# remove unused paddle/libs/__init__.py | ||
os.remove(libs_path+'/__init__.py') | ||
package_dir['paddle.libs']=libs_path | ||
|
||
# change rpath of core.so, add $ORIGIN/../libs/ to it. | ||
# 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 | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, need some checks. |
||
|
||
setup(name='${PACKAGE_NAME}', | ||
version='${PADDLE_VERSION}', | ||
|
@@ -128,6 +152,5 @@ setup(name='${PACKAGE_NAME}', | |
ext_modules=[Extension('_foo', ['stub.cc'])], | ||
package_data=package_data, | ||
package_dir=package_dir, | ||
scripts=paddle_bins, | ||
data_files=[(paddle_rt_lib_dir, paddle_rt_libs)] | ||
scripts=paddle_bins | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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打包的时候,会找不到这个目录。不过可以尝试在打包后删除这个文件。