From 2dacf28b669228d409a81e4037334aa8576036c1 Mon Sep 17 00:00:00 2001 From: Anders Papitto Date: Wed, 24 Oct 2018 13:14:45 -0700 Subject: [PATCH] link libgloo_cuda.a explictly from setup.py (#12951) Summary: rather than pass a list through a text file Pull Request resolved: https://github.com/pytorch/pytorch/pull/12951 Differential Revision: D10528309 Pulled By: anderspapitto fbshipit-source-id: d94befcd61b6304815859694b623046f256462df --- setup.py | 22 +++------------------- torch/lib/THD/CMakeLists.txt | 4 ---- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index 1e92161bff7059..023da4664244af 100644 --- a/setup.py +++ b/setup.py @@ -571,23 +571,6 @@ def load(filename): print(" > pip install ninja") -def monkey_patch_THD_link_flags(): - ''' - THD's dynamic link deps are not determined until after build_deps is run - So, we need to monkey-patch them in later - ''' - # read tmp_install_path/THD_deps.txt for THD's dynamic linkage deps - with open(tmp_install_path + '/THD_deps.txt', 'r') as f: - thd_deps_ = f.read() - thd_deps = [] - # remove empty lines - for l in thd_deps_.split(';'): - if l != '': - thd_deps.append(l) - - C.extra_link_args += thd_deps - - def monkey_patch_C10D_inc_flags(): ''' C10D's include deps are not determined until after build c10d is run, so @@ -639,7 +622,6 @@ def run(self): print('-- Not using NCCL') if USE_DISTRIBUTED: print('-- Building with THD distributed package ') - monkey_patch_THD_link_flags() if IS_LINUX: print('-- Building with c10d distributed package ') monkey_patch_C10D_inc_flags() @@ -862,6 +844,7 @@ def run(self): THD_LIB = os.path.join(lib_path, 'libTHD.a') NCCL_LIB = os.path.join(lib_path, 'libnccl.so.2') C10D_LIB = os.path.join(lib_path, 'libc10d.a') +GLOO_CUDA_LIB = os.path.join(lib_path, 'libgloo_cuda.a') # static library only if IS_DARWIN: @@ -973,9 +956,10 @@ def run(self): if IS_LINUX: extra_compile_args.append('-DUSE_C10D') main_sources.append('torch/csrc/distributed/c10d/init.cpp') + main_link_args.append(C10D_LIB) if USE_CUDA: main_sources.append('torch/csrc/distributed/c10d/ddp.cpp') - main_link_args.append(C10D_LIB) + main_link_args.append(GLOO_CUDA_LIB) if USE_CUDA: nvtoolext_lib_name = None diff --git a/torch/lib/THD/CMakeLists.txt b/torch/lib/THD/CMakeLists.txt index b4ed95a46a2d65..0811b01128f166 100644 --- a/torch/lib/THD/CMakeLists.txt +++ b/torch/lib/THD/CMakeLists.txt @@ -134,7 +134,6 @@ EXCLUDE_DIR(all_cpp ".*/generic/.*\\.cpp$") # Need to include external NCCL first IF(DISTRIBUTED_NCCL_FOUND) INCLUDE_DIRECTORIES(${NCCL_INCLUDE_DIRS}) - FILE(APPEND "${CMAKE_INSTALL_PREFIX}/THD_deps.txt" "${NCCL_LIBRARIES};") ENDIF() INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) @@ -142,11 +141,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ADD_LIBRARY(THD STATIC ${all_cpp}) set_property(TARGET THD PROPERTY POSITION_INDEPENDENT_CODE ON) -FILE(WRITE "${CMAKE_INSTALL_PREFIX}/THD_deps.txt" "${CAFFE2_LIBRARIES};") - IF(MPI_FOUND) INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) - FILE(APPEND "${CMAKE_INSTALL_PREFIX}/THD_deps.txt" "${MPI_LIBRARIES};") IF(MPI_COMPILE_FLAGS) MESSAGE(STATUS "MPI_COMPILE_FLAGS: ${MPI_COMPILE_FLAGS}")