Skip to content

Commit 2b987cf

Browse files
caiomcbrchhwang
andauthored
Resolve IBVerbs Loading Issues (#648)
Some systems do not include libibverbs.so when installing ibverbs; instead, they only provide libibverbs.so1. This PR updates the CMake file to search for this library and modifies the wrapper to load it. --------- Co-authored-by: Changho Hwang <[email protected]>
1 parent a38c2ee commit 2b987cf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ find_package(IBVerbs)
148148
find_package(NUMA REQUIRED)
149149
find_package(Threads REQUIRED)
150150

151+
set(CMAKE_COLOR_DIAGNOSTICS ON)
152+
function(msg_red text)
153+
string(ASCII 27 ESC)
154+
message("${ESC}[31m${text}${ESC}[0m")
155+
endfunction()
156+
157+
if(NOT IBVERBS_FOUND)
158+
msg_red("libibverbs not found. Install libibverbs-dev or rdma-core-devel.")
159+
endif()
160+
151161
include(FetchContent)
152162
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
153163
FetchContent_MakeAvailable(json)

src/include/ibverbs_wrapper.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ struct IBVerbs {
1717
// Static method to initialize the library
1818
static void initialize() {
1919
initialized = true;
20-
handle = dlopen("libibverbs.so", RTLD_NOW);
20+
21+
// Try different versions of libibverbs
22+
const char* lib_possible_names[] = {
23+
"libibverbs.so",
24+
"libibverbs.so.1",
25+
};
26+
for (int i = 0; lib_possible_names[i] != nullptr; i++) {
27+
handle = dlopen(lib_possible_names[i], RTLD_NOW);
28+
if (handle) {
29+
break;
30+
}
31+
}
2132
if (!handle) {
2233
throw mscclpp::IbError("Failed to load libibverbs: " + std::string(dlerror()), errno);
2334
}

0 commit comments

Comments
 (0)