Build distributed libs in build_libtorch.py (#14037)
authorZeming Lin <ebetica0@gmail.com>
Fri, 30 Nov 2018 22:43:29 +0000 (14:43 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 30 Nov 2018 22:46:36 +0000 (14:46 -0800)
Summary:
This patch detects and builds c10d and gloo for the C++ API.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14037

Reviewed By: ezyang

Differential Revision: D13283801

Pulled By: ebetica

fbshipit-source-id: 006dbb691344819833da6b4b844c1f0572942135

tools/build_libtorch.py
tools/build_pytorch_libs.sh

index 8b6f030..6122bea 100644 (file)
@@ -5,6 +5,7 @@ import subprocess
 import sys
 
 from setup_helpers.cuda import USE_CUDA
+from setup_helpers.dist_check import USE_DISTRIBUTED, USE_GLOO_IBVERBS, IS_LINUX
 from setup_helpers.env import check_env_flag
 
 if __name__ == '__main__':
@@ -31,6 +32,11 @@ if __name__ == '__main__':
         command.append('--use-cuda')
         if os.environ.get('USE_CUDA_STATIC_LINK', False):
             command.append('--cuda-static-link')
+    if USE_DISTRIBUTED and IS_LINUX:
+        if USE_GLOO_IBVERBS:
+            command.append('--use-gloo-ibverbs')
+        command.append('--use-distributed')
+
     command.append('caffe2')
 
     sys.stdout.flush()
index 0921bd7..11d5ef5 100755 (executable)
@@ -59,6 +59,9 @@ while [[ $# -gt 0 ]]; do
       --use-cuda)
           USE_CUDA=1
           ;;
+      --use-distributed)
+          USE_DISTRIBUTED=1
+          ;;
       --use-fbgemm)
           USE_FBGEMM=1
           ;;