Skip to content

Commit 3ad438c

Browse files
authored
Fix build when nvtools is missing (#3698)
1 parent 203d4f8 commit 3ad438c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ find_package(Torch REQUIRED)
7070
# config is used for standalone C++ binaries that link against torch).
7171
# The `libtorch_python.so` library defines some of the glue code between
7272
# torch/python via pybind and is required by VLLM extensions for this
73-
# reason. So, add it by manually using `append_torchlib_if_found` from
74-
# torch's cmake setup.
73+
# reason. So, add it by manually with `find_library` using torch's
74+
# installed library path.
7575
#
76-
append_torchlib_if_found(torch_python)
76+
find_library(torch_python_LIBRARY torch_python PATHS
77+
"${TORCH_INSTALL_PREFIX}/lib")
7778

7879
#
7980
# Set up GPU language and check the torch version and warn if it isn't

cmake/utils.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ endmacro()
281281
# not provided.
282282
# COMPILE_FLAGS <flags> - Extra compiler flags passed to NVCC/hip.
283283
# INCLUDE_DIRECTORIES <dirs> - Extra include directories.
284-
# LINK_LIBRARIES <libraries> - Extra link libraries.
284+
# LIBRARIES <libraries> - Extra link libraries.
285285
# WITH_SOABI - Generate library with python SOABI suffix name.
286286
#
287287
# Note: optimization level/debug info is set via cmake build type.
@@ -327,8 +327,17 @@ function (define_gpu_extension_target GPU_MOD_NAME)
327327
target_include_directories(${GPU_MOD_NAME} PRIVATE csrc
328328
${GPU_INCLUDE_DIRECTORIES})
329329

330-
target_link_libraries(${GPU_MOD_NAME} PRIVATE ${TORCH_LIBRARIES}
330+
target_link_libraries(${GPU_MOD_NAME} PRIVATE torch ${torch_python_LIBRARY}
331331
${GPU_LIBRARIES})
332332

333+
# Don't use `TORCH_LIBRARIES` for CUDA since it pulls in a bunch of
334+
# dependencies that are not necessary and may not be installed.
335+
if (GPU_LANGUAGE STREQUAL "CUDA")
336+
target_link_libraries(${GPU_MOD_NAME} PRIVATE ${CUDA_CUDA_LIB}
337+
${CUDA_LIBRARIES})
338+
else()
339+
target_link_libraries(${GPU_MOD_NAME} PRIVATE ${TORCH_LIBRARIES})
340+
endif()
341+
333342
install(TARGETS ${GPU_MOD_NAME} LIBRARY DESTINATION ${GPU_DESTINATION})
334343
endfunction()

0 commit comments

Comments
 (0)