Skip to content

Commit e5eac4a

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> (cherry picked from commit cfe17a3)
1 parent 41495b1 commit e5eac4a

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
@@ -389,7 +389,13 @@ static inline void _load_library_path(std::string dso_path) {
389389
if (!dso_handle) {
390390
throw deepmd::deepmd_exception(
391391
dso_path +
392-
" is not found! You can add the library directory to LD_LIBRARY_PATH");
392+
" is not found or fails to load! You can add the library directory to "
393+
"LD_LIBRARY_PATH."
394+
#ifndef _WIN32
395+
" Error message: " +
396+
std::string(dlerror())
397+
#endif
398+
);
393399
}
394400
}
395401

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)