Skip to content

Commit cfe17a3

Browse files
fix: print dlerror if dlopen fails (#4485)
xref: deepmodeling/deepmd-gnn#44 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced error messages for library loading failures on non-Windows platforms. - Updated thread management environment variable checks for improved compatibility. - Added support for mixed types in tensor input handling, allowing for more flexible configurations. - **Bug Fixes** - Improved error reporting for dynamic library loading issues. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2525ab2 commit cfe17a3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/api_cc/src/common.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,13 @@ static inline void _load_library_path(std::string dso_path) {
390390
if (!dso_handle) {
391391
throw deepmd::deepmd_exception(
392392
dso_path +
393-
" is not found! You can add the library directory to LD_LIBRARY_PATH");
393+
" is not found or fails to load! You can add the library directory to "
394+
"LD_LIBRARY_PATH."
395+
#ifndef _WIN32
396+
" Error message: " +
397+
std::string(dlerror())
398+
#endif
399+
);
394400
}
395401
}
396402

source/lib/src/gpu/cudart/cudart_stub.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ void *DP_cudart_dlopen(char *libname) {
2525
#endif
2626
if (!dso_handle) {
2727
std::cerr << "DeePMD-kit: Cannot find " << libname << std::endl;
28+
#ifndef _WIN32
29+
std::cerr << "DeePMD-kit: Error message: " << std::string(dlerror())
30+
<< std::endl;
31+
#endif
2832
return nullptr;
2933
}
3034
std::cerr << "DeePMD-kit: Successfully load " << libname << std::endl;

0 commit comments

Comments
 (0)