mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
gloo: fix building system gloo with CUDA/HIP (#146637)
Fix incorrect linking of Gloo's libraries when building with system Gloo. Previously, either Gloo's native library or Gloo's CUDA library were linked. However, Gloo had changed such that all users of Gloo must link the native library, and can optionally link the CUDA or HIP library for Gloo + CUDA/HIP support. This had been updated when building/linking with vendored Gloo, but not when using system Gloo. Fixes: #146239 Reported-by: Adam J Stewart <ajstewart426@gmail.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/146637 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
3a2c3c8ed3
commit
93da9952a7
@ -1235,10 +1235,17 @@ if(USE_GLOO)
|
||||
if(NOT Gloo_FOUND)
|
||||
message(FATAL_ERROR "Cannot find gloo")
|
||||
endif()
|
||||
message("Found gloo: ${Gloo_LIBRARY}")
|
||||
message("Found gloo: ${Gloo_NATIVE_LIBRARY}, cuda lib: ${Gloo_CUDA_LIBRARY}, hip lib: ${Gloo_HIP_LIBRARY}")
|
||||
message("Found gloo include directories: ${Gloo_INCLUDE_DIRS}")
|
||||
add_library(gloo SHARED IMPORTED)
|
||||
set_target_properties(gloo PROPERTIES IMPORTED_LOCATION ${Gloo_LIBRARY})
|
||||
set_target_properties(gloo PROPERTIES IMPORTED_LOCATION ${Gloo_NATIVE_LIBRARY})
|
||||
if(USE_CUDA)
|
||||
add_library(gloo_cuda SHARED IMPORTED)
|
||||
set_target_properties(gloo_cuda PROPERTIES IMPORTED_LOCATION ${Gloo_CUDA_LIBRARY})
|
||||
elseif(USE_ROCM)
|
||||
add_library(gloo_hip SHARED IMPORTED)
|
||||
set_target_properties(gloo_hip PROPERTIES IMPORTED_LOCATION ${Gloo_HIP_LIBRARY})
|
||||
endif()
|
||||
# need to use Gloo_INCLUDE_DIRS over third_party/gloo to find Gloo's auto-generated config.h
|
||||
include_directories(BEFORE SYSTEM ${Gloo_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user