Skip to content

Commit

Permalink
link libgloo_cuda.a explictly from setup.py (pytorch#12951)
Browse files Browse the repository at this point in the history
Summary:
rather than pass a list through a text file
Pull Request resolved: pytorch#12951

Differential Revision: D10528309

Pulled By: anderspapitto

fbshipit-source-id: d94befcd61b6304815859694b623046f256462df
  • Loading branch information
anderspapitto authored and facebook-github-bot committed Oct 24, 2018
1 parent dd7c2d4 commit 2dacf28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
22 changes: 3 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions torch/lib/THD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,15 @@ 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})

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}")
Expand Down

0 comments on commit 2dacf28

Please sign in to comment.