From cb0de9dbb985fd1cb1cea2257ae629529a3d8d32 Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Tue, 3 Jan 2023 19:58:57 +0800 Subject: [PATCH] open dvpp utils by absolute path Signed-off-by: zhoufeng --- cmake/package_tar.cmake | 2 +- .../dataset/kernels/image/dvpp/acl_adapter.cc | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmake/package_tar.cmake b/cmake/package_tar.cmake index 85b058b7b3f..95e02bbb1ed 100644 --- a/cmake/package_tar.cmake +++ b/cmake/package_tar.cmake @@ -100,7 +100,7 @@ if(ENABLE_MINDDATA) if(ENABLE_ACL) install( TARGETS dvpp_utils - DESTINATION ${INSTALL_PLUGIN_DIR} + DESTINATION ${INSTALL_PLUGIN_DIR}/ascend COMPONENT mindspore ) endif() diff --git a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/acl_adapter.cc b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/acl_adapter.cc index 5192d166cc9..17a32ae91cb 100644 --- a/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/acl_adapter.cc +++ b/mindspore/ccsrc/minddata/dataset/kernels/image/dvpp/acl_adapter.cc @@ -14,13 +14,14 @@ * limitations under the License. */ #include "minddata/dataset/kernels/image/dvpp/acl_adapter.h" +#include #include #include "utils/ms_context.h" namespace mindspore { namespace dataset { namespace { -constexpr auto kAclPluginFileName = "libdvpp_utils.so"; +constexpr auto kAclPluginRelatedPath = "./lib/plugin/ascend/libdvpp_utils.so"; } // namespace AclAdapter &AclAdapter::GetInstance() { static AclAdapter instance{}; @@ -40,9 +41,17 @@ void AclAdapter::InitPlugin() { } #endif #if !defined(_WIN32) && !defined(_WIN64) - plugin_handle_ = dlopen(kAclPluginFileName, RTLD_LAZY | RTLD_LOCAL); + Dl_info dl_info; + if (dladdr(reinterpret_cast(AclAdapter::GetInstance), &dl_info) == 0) { + MS_LOG(INFO) << "Get dladdr error"; + return; + } + std::string cur_so_path = dl_info.dli_fname; + std::string acl_plugin_path = std::string(dirname(cur_so_path.data())) + "/" + kAclPluginRelatedPath; + + plugin_handle_ = dlopen(acl_plugin_path.c_str(), RTLD_LAZY | RTLD_LOCAL); if (plugin_handle_ == nullptr) { - MS_LOG(INFO) << "Cannot dlopen " << kAclPluginFileName << ", result = " << GetDlErrorMsg() + MS_LOG(INFO) << "Cannot dlopen " << acl_plugin_path << ", result = " << GetDlErrorMsg() << ", it can be ignored if not running on ascend."; return; }