Fix NCCL detection by Gloo (#82773)

Instruct Gloo to always use bundled version of the library by passing `NCCL_EXTERNAL`
Otherwise, it would link with shared library if one could be found in the system
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82773
Approved by: https://github.com/ngimel
This commit is contained in:
Nikita Shulga 2022-08-03 23:26:44 +00:00 committed by PyTorch MergeBot
parent 112ec24f09
commit 83086b7f45

View File

@ -1443,6 +1443,11 @@ if(USE_GLOO)
get_target_property(_include_dirs uv_a INCLUDE_DIRECTORIES)
set_target_properties(uv_a PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_include_dirs}")
endif()
if(USE_NCCL AND NOT USE_SYSTEM_NCCL)
# Tell Gloo build system to use bundled NCCL, see
# https://github.com/facebookincubator/gloo/blob/950c0e23819779a9e0c70b861db4c52b31d1d1b2/cmake/Dependencies.cmake#L123
set(NCCL_EXTERNAL ON)
endif()
# gloo uses cuda_add_library
torch_update_find_cuda_flags()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/gloo)