Skip to content

Commit

Permalink
fix: print dlerror if dlopen fails (#4485)
Browse files Browse the repository at this point in the history
xref: njzjz/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)
  • Loading branch information
njzjz committed Dec 23, 2024
1 parent 41495b1 commit e5eac4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/api_cc/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,13 @@ 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
);
}
}

Expand Down
4 changes: 4 additions & 0 deletions source/lib/src/gpu/cudart/cudart_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ 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;
Expand Down

0 comments on commit e5eac4a

Please sign in to comment.