Skip to content

Commit df5e232

Browse files
malfetpytorchmergebot
authored andcommitted
[BE] Delete NCCL slimming (pytorch#146943)
It was added by pytorch#35843 and served its purpose when everything was linked statically in libtorch_cuda.so, but for all our releases it's no longer relevant as nccl is now a dynamic dependency of libtorch_cuda.so Besides, It does not work with CXX11 ABI anyway, and creates problems with newer version of NCCL, when two `collectvies.o` are package into library archive. Pull Request resolved: pytorch#146943 Approved by: https://github.com/Skylion007, https://github.com/atalman
1 parent a58f421 commit df5e232

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

cmake/External/nccl.cmake

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,42 +55,8 @@ if(NOT __NCCL_INCLUDED)
5555
INSTALL_COMMAND ""
5656
)
5757

58-
# Detect objcopy version
59-
execute_process(COMMAND "${CMAKE_OBJCOPY}" "--version" OUTPUT_VARIABLE OBJCOPY_VERSION_STR)
60-
string(REGEX REPLACE "GNU objcopy .+ ([0-9])\\.([0-9]+).*" "\\1" OBJCOPY_VERSION_MAJOR ${OBJCOPY_VERSION_STR})
61-
string(REGEX REPLACE "GNU objcopy .+ ([0-9])\\.([0-9]+).*" "\\2" OBJCOPY_VERSION_MINOR ${OBJCOPY_VERSION_STR})
62-
63-
# TODO: Replace me with SKIP_NCCL_SLIMMING option (and investigate why it does not work on newer compilers)
64-
if("$ENV{BUILD_ENVIRONMENT}" MATCHES ".*-libtorch-cxx11-abi$")
65-
# See https://github.com/pytorch/pytorch/issues/83887
66-
message(WARNING "Skip NCCL library slimming for cxx11-abi builds")
67-
set(__NCCL_LIBRARY_DEP nccl_external)
68-
set(NCCL_LIBRARIES ${__NCCL_BUILD_DIR}/lib/libnccl_static.a)
69-
elseif((${OBJCOPY_VERSION_MAJOR} GREATER 2) OR ((${OBJCOPY_VERSION_MAJOR} EQUAL 2) AND (${OBJCOPY_VERSION_MINOR} GREATER 27)))
70-
message(WARNING "Enabling NCCL library slimming")
71-
add_custom_command(
72-
OUTPUT "${__NCCL_BUILD_DIR}/lib/libnccl_slim_static.a"
73-
DEPENDS nccl_external
74-
COMMAND "${CMAKE_COMMAND}" -E make_directory "${__NCCL_BUILD_DIR}/objects"
75-
COMMAND cd objects
76-
COMMAND "${CMAKE_AR}" x "${__NCCL_BUILD_DIR}/lib/libnccl_static.a"
77-
COMMAND for obj in all_gather_* all_reduce_* broadcast_* reduce_*.o$<SEMICOLON> do "${CMAKE_OBJCOPY}" --remove-relocations .nvFatBinSegment --remove-section __nv_relfatbin $$obj$<SEMICOLON> done
78-
COMMAND "${CMAKE_AR}" cr "${__NCCL_BUILD_DIR}/lib/libnccl_slim_static.a" "*.o"
79-
COMMAND "${CMAKE_AR}" xN 1 "${__NCCL_BUILD_DIR}/lib/libnccl_static.a" net.o
80-
COMMAND "${CMAKE_AR}" q "${__NCCL_BUILD_DIR}/lib/libnccl_slim_static.a" net.o
81-
COMMAND cd -
82-
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${__NCCL_BUILD_DIR}/objects"
83-
WORKING_DIRECTORY "${__NCCL_BUILD_DIR}"
84-
COMMENT "Slimming NCCL"
85-
)
86-
add_custom_target(nccl_slim_external DEPENDS "${__NCCL_BUILD_DIR}/lib/libnccl_slim_static.a")
87-
set(__NCCL_LIBRARY_DEP nccl_slim_external)
88-
set(NCCL_LIBRARIES ${__NCCL_BUILD_DIR}/lib/libnccl_slim_static.a)
89-
else()
90-
message(WARNING "Objcopy version is too old to support NCCL library slimming")
91-
set(__NCCL_LIBRARY_DEP nccl_external)
92-
set(NCCL_LIBRARIES ${__NCCL_BUILD_DIR}/lib/libnccl_static.a)
93-
endif()
58+
set(__NCCL_LIBRARY_DEP nccl_external)
59+
set(NCCL_LIBRARIES ${__NCCL_BUILD_DIR}/lib/libnccl_static.a)
9460

9561
set(NCCL_FOUND TRUE)
9662
add_library(__caffe2_nccl INTERFACE)

0 commit comments

Comments
 (0)