diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index b2a94e62a1e0b801961f0a94626676bf7e254926..e39affb84cdb42946c81aace5814d58025118a6f 100755 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -370,7 +370,7 @@ if is_compiled_with_cinn(): runtime_include_dir = os.path.join(package_dir, "libs") cuh_file = os.path.join(runtime_include_dir, "cinn_cuda_runtime_source.cuh") if os.path.exists(cuh_file): - os.environ['runtime_include_dir'] = runtime_include_dir + os.environ.setdefault('runtime_include_dir', runtime_include_dir) disable_static() diff --git a/python/setup.py.in b/python/setup.py.in index 8b6a456865176f50aa7ae5d67b7eb0e6099cf034..bbeb1aa4476735eef0c63cd6ff67e6f633b5abc1 100755 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -502,6 +502,10 @@ if '${WITH_CINN}' == 'ON': shutil.copy('${CINN_INCLUDE_DIR}/cinn/runtime/cuda/cinn_cuda_runtime_source.cuh', libs_path) package_data['paddle.libs']+=['libcinnapi.so'] package_data['paddle.libs']+=['cinn_cuda_runtime_source.cuh'] + if '${CMAKE_BUILD_TYPE}' == 'Release' and os.name != 'nt': + command = "patchelf --set-rpath '$ORIGIN/' %s/${CINN_LIB_NAME}" % libs_path + if os.system(command) != 0: + raise Exception("patch %s/${CINN_LIB_NAME} failed, command: %s" % (libs_path, command)) if '${WITH_PSLIB}' == 'ON': shutil.copy('${PSLIB_LIB}', libs_path)