Skip to content

Commit 20b3084

Browse files
[#6102][fix] support non-system python installation
Signed-off-by: Yuan Tong <[email protected]>
1 parent d3467f9 commit 20b3084

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

cpp/tensorrt_llm/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ if(TARGET ${NIXL_WRAPPER_TARGET})
294294
endif()
295295

296296
if(NOT WIN32)
297-
set_target_properties(${SHARED_TARGET} PROPERTIES BUILD_RPATH "$ORIGIN")
297+
# Load libraries at $PREFIX/lib from
298+
# $PREFIX/lib/python3.12/site-packages/tensorrt_llm/libs
299+
set_target_properties(${SHARED_TARGET}
300+
PROPERTIES BUILD_RPATH "$ORIGIN;$ORIGIN/../../../..")
298301
endif()
299302

300303
if(BUILD_PYT)

cpp/tensorrt_llm/nanobind/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ endif()
4141
target_link_libraries(
4242
${TRTLLM_NB_MODULE}
4343
PUBLIC ${SHARED_TARGET}
44-
${UNDEFINED_FLAG}
45-
${NO_AS_NEEDED_FLAG}
4644
${Python3_LIBRARIES}
4745
${TORCH_LIBRARIES}
4846
torch_python
@@ -54,10 +52,14 @@ target_compile_definitions(
5452
PYBIND11_DETAILED_ERROR_MESSAGES=1)
5553

5654
if(NOT WIN32)
57-
set_target_properties(
58-
${TRTLLM_NB_MODULE}
59-
PROPERTIES
60-
LINK_FLAGS
61-
"-Wl,-rpath,'$ORIGIN/libs' -Wl,-rpath,'$ORIGIN/../nvidia/nccl/lib' ${AS_NEEDED_FLAG} ${UNDEFINED_FLAG}"
55+
set(TRTLLM_NB_MODULE_RPATH_LIST
56+
"$ORIGIN/libs" # TRTLLM libraries
57+
"$ORIGIN/../../.." # Shared libraries under $PREFIX/lib
58+
"$ORIGIN/../nvidia/nccl/lib" # NCCL libraries
6259
)
60+
set_target_properties(${TRTLLM_NB_MODULE}
61+
PROPERTIES BUILD_RPATH "${TRTLLM_NB_MODULE_RPATH_LIST}")
62+
set_target_properties(
63+
${TRTLLM_NB_MODULE} PROPERTIES LINK_FLAGS
64+
"${AS_NEEDED_FLAG} ${UNDEFINED_FLAG}")
6365
endif()

cpp/tensorrt_llm/pybind/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ endif()
4343
target_link_libraries(
4444
${TRTLLM_PYBIND_MODULE}
4545
PUBLIC ${SHARED_TARGET}
46-
${UNDEFINED_FLAG}
47-
${NO_AS_NEEDED_FLAG}
4846
${Python3_LIBRARIES}
4947
${TORCH_LIBRARIES}
5048
torch_python
@@ -56,10 +54,15 @@ target_compile_definitions(
5654
PYBIND11_DETAILED_ERROR_MESSAGES=1)
5755

5856
if(NOT WIN32)
59-
set_target_properties(
60-
${TRTLLM_PYBIND_MODULE}
61-
PROPERTIES
62-
LINK_FLAGS
63-
"-Wl,-rpath,'$ORIGIN/libs' -Wl,-rpath,'$ORIGIN/../nvidia/nccl/lib' ${AS_NEEDED_FLAG} ${UNDEFINED_FLAG}"
57+
set(TRTLLM_PYBIND_MODULE_RPATH_LIST
58+
"$ORIGIN/libs" # TRTLLM libraries
59+
"$ORIGIN/../../.." # Shared libraries under $PREFIX/lib
60+
"$ORIGIN/../nvidia/nccl/lib" # NCCL libraries
6461
)
62+
set_target_properties(
63+
${TRTLLM_PYBIND_MODULE} PROPERTIES BUILD_RPATH
64+
"${TRTLLM_PYBIND_MODULE_RPATH_LIST}")
65+
set_target_properties(
66+
${TRTLLM_PYBIND_MODULE} PROPERTIES LINK_FLAGS
67+
"${AS_NEEDED_FLAG} ${UNDEFINED_FLAG}")
6568
endif()

0 commit comments

Comments
 (0)