From b3063df1a08bc785b149bbba6c862aa5d9dab4bf Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 21 Dec 2024 22:12:53 -0500 Subject: [PATCH 1/2] fix: print dlerror if dlopen fails xref: https://github.com/njzjz/deepmd-gnn/issues/44 --- source/api_cc/src/common.cc | 6 +++++- source/lib/src/gpu/cudart/cudart_stub.cc | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/api_cc/src/common.cc b/source/api_cc/src/common.cc index c51ae9a8b4..f8e69cf3ae 100644 --- a/source/api_cc/src/common.cc +++ b/source/api_cc/src/common.cc @@ -390,7 +390,11 @@ static inline void _load_library_path(std::string dso_path) { if (!dso_handle) { throw deepmd::deepmd_exception( dso_path + - " is not found! You can add the library directory to LD_LIBRARY_PATH"); + " is not found or fails to load! You can add the library directory to LD_LIBRARY_PATH." +#ifndef _WIN32 + " Error message: " + std::string(dlerror()) +#endif + ); } } diff --git a/source/lib/src/gpu/cudart/cudart_stub.cc b/source/lib/src/gpu/cudart/cudart_stub.cc index 8083a0a89d..3a735606eb 100644 --- a/source/lib/src/gpu/cudart/cudart_stub.cc +++ b/source/lib/src/gpu/cudart/cudart_stub.cc @@ -25,6 +25,9 @@ void *DP_cudart_dlopen(char *libname) { #endif if (!dso_handle) { std::cerr << "DeePMD-kit: Cannot find " << libname << std::endl; +#ifndef _WIN32 + std::cerr << "DeePMD-kit: Error message: " << std::string(dlerror()) << std::endl; +#endif return nullptr; } std::cerr << "DeePMD-kit: Successfully load " << libname << std::endl; From 40d2f54f63ffd2d1b48113855fabe1e297ae2888 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 03:14:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/api_cc/src/common.cc | 6 ++++-- source/lib/src/gpu/cudart/cudart_stub.cc | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/api_cc/src/common.cc b/source/api_cc/src/common.cc index f8e69cf3ae..d3cad083bd 100644 --- a/source/api_cc/src/common.cc +++ b/source/api_cc/src/common.cc @@ -390,9 +390,11 @@ static inline void _load_library_path(std::string dso_path) { if (!dso_handle) { throw deepmd::deepmd_exception( dso_path + - " is not found or fails to load! You can add the library directory to LD_LIBRARY_PATH." + " is not found or fails to load! You can add the library directory to " + "LD_LIBRARY_PATH." #ifndef _WIN32 - " Error message: " + std::string(dlerror()) + " Error message: " + + std::string(dlerror()) #endif ); } diff --git a/source/lib/src/gpu/cudart/cudart_stub.cc b/source/lib/src/gpu/cudart/cudart_stub.cc index 3a735606eb..cfbabd6f5e 100644 --- a/source/lib/src/gpu/cudart/cudart_stub.cc +++ b/source/lib/src/gpu/cudart/cudart_stub.cc @@ -26,7 +26,8 @@ void *DP_cudart_dlopen(char *libname) { if (!dso_handle) { std::cerr << "DeePMD-kit: Cannot find " << libname << std::endl; #ifndef _WIN32 - std::cerr << "DeePMD-kit: Error message: " << std::string(dlerror()) << std::endl; + std::cerr << "DeePMD-kit: Error message: " << std::string(dlerror()) + << std::endl; #endif return nullptr; }