aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure
diff options
context:
space:
mode:
authorGravatar Jeroen Bédorf <jeroen@minds.ai>2017-05-12 10:05:33 -0700
committerGravatar Jeroen Bédorf <jeroen@minds.ai>2017-05-12 10:05:33 -0700
commitb78b5414b8ef61d41bb2bd65bd4618c3555dbf15 (patch)
tree94ef55c765bd033d7b2d4e58da228dea31c43006 /configure
parent45fc73dc09d6316423be98d07e4824870a653d97 (diff)
MPI based communication path for tensor exchange operations in
distributed TensorFlow
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure78
1 files changed, 78 insertions, 0 deletions
diff --git a/configure b/configure
index 308369efd3..dc4986c6a1 100755
--- a/configure
+++ b/configure
@@ -763,6 +763,84 @@ done
# end of if "$TF_NEED_OPENCL" == "1"
fi
+
+while [ "$TF_NEED_MPI" == "" ]; do
+ read -p "Do you wish to build TensorFlow with "\
+"MPI support? [y/N] " INPUT
+ case $INPUT in
+ [Yy]* ) echo "MPI support will be enabled for "\
+"TensorFlow"; TF_NEED_MPI=1;;
+ [Nn]* ) echo "MPI support will not be enabled for "\
+"TensorFlow"; TF_NEED_MPI=0;;
+ "" ) echo "MPI support will not be enabled for "\
+"TensorFlow"; TF_NEED_MPI=0;;
+ * ) echo "Invalid selection: " $INPUT;;
+ esac
+done
+
+# Find out where the MPI toolkit is installed
+while true; do
+ if [ "$TF_NEED_MPI" == "0" ]; then
+ break;
+ fi
+
+ fromuser=""
+ if [ -z "$MPI_HOME" ]; then
+ #Get the base folder by removing the bin path
+ default_path=$(dirname $(dirname $(which mpirun)) || dirname $(dirname $(which mpiexec)) || true)
+ read -p "Please specify the MPI toolkit folder. [Default is $default_mpi_path]: " MPI_HOME
+ fromuser="1"
+ if [ -z "$MPI_HOME" ]; then
+ MPI_HOME=$default_path
+ fi
+ fi
+
+ #Check that the include and library folders are where we expect them to be
+ if [ -e "$MPI_HOME/include" -a -e "$MPI_HOME/lib" ]; then
+ break
+ fi
+
+ echo "Invalid path to the MPI Toolkit. ${MPI_HOME}/include or ${MPI_HOME}/lib cannot be found."
+ if [ -z "$fromuser" ]; then
+ exit 1
+ fi
+
+ # Retry
+ MPI_HOME=""
+done
+
+
+if [ "$TF_NEED_MPI" == "1" ]; then
+ write_to_bazelrc 'build --define with_mpi_support=true'
+
+ #Link the MPI header files
+ ln -sf "${MPI_HOME}/include/mpi.h" third_party/mpi/mpi.h
+
+
+ #Determine if we use OpenMPI or MVAPICH, these require different header files
+ #to be included here to make bazel dependency checker happy
+
+ if [ -e "${MPI_HOME}/include/mpi_portable_platform.h" ]; then
+ #OpenMPI
+ ln -sf "${MPI_HOME}/include/mpi_portable_platform.h" third_party/mpi/
+ sed -i -e "s/MPI_LIB_IS_OPENMPI=False/MPI_LIB_IS_OPENMPI=True/" third_party/mpi/mpi.bzl
+ else
+ #MVAPICH / MPICH
+ ln -sf "${MPI_HOME}/include/mpio.h" third_party/mpi/
+ ln -sf "${MPI_HOME}/include/mpicxx.h" third_party/mpi/
+ sed -i -e "s/MPI_LIB_IS_OPENMPI=True/MPI_LIB_IS_OPENMPI=False/" third_party/mpi/mpi.bzl
+ fi
+
+
+ if [ -e "${MPI_HOME}/lib/libmpi.so" ]; then
+ ln -sf "${MPI_HOME}/lib/libmpi.so" third_party/mpi/
+ else
+ echo "Cannot find the MPI library file in ${MPI_HOME}/lib "
+ exit 1
+ fi
+fi
+
+
# TODO(gunan): Remove once bazel correctly handles changes in remote repositories.
bazel clean
echo "Configuration finished"