Skip to content

Commit

Permalink
updata horovod build
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjianwei committed Jun 1, 2020
1 parent 4385be7 commit 95b5158
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions tools/build_horovod_centos_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
python_dir=`which python`
python_vision=`python --version 2>&1`
python_vision=${python_vision#* }
python_vision=${python_vision%% *}
echo $python_vision
if version_lt $python_vision 3.6 ;then
echo Your python vision should be equal or greater than 3.6.9.
echo We suggest you install Anaconda: https://www.anaconda.com/products/individual#linux
echo and run '"sh build_horovod_centos_env.sh"' again.
exit
fi
python_dir=${python_dir%/*}
site_packages_dir=`python -m site --user-site`
site_packages_dir=`python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
work_dir=`pwd`
echo $python_dir
echo $site_packages_dir
Expand All @@ -27,6 +29,7 @@ function build_gcc_env()
if version_lt $gcc_vision 7.0 ;then
echo " gcc $gcc_vision should be updated"
#sudo yum -y install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
#NOTE: yum issue: https://blog.csdn.net/qq_30938705/article/details/87281698
sudo yum install centos-release-scl
sudo yum install devtoolset-7
source /opt/rh/devtoolset-7/enable
Expand All @@ -36,7 +39,8 @@ function build_gcc_env()
function build_openmpi()
{
if [ ! -f openmpi-4.0.2.tar.gz ];then
echo wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.2.tar.gz
echo wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.2.tar.gz
wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.2.tar.gz
fi
if [ ! -f openmpi-4.0.2 ];then
tar zxvf openmpi-4.0.2.tar.gz
Expand All @@ -53,16 +57,26 @@ function build_horovod()
{
if [ ! -d horovod ];then
source $work_dir/horovod.env
git clone --recursive https://github.com/uber/horovod.git
git clone --recursive https://github.com/8z8z8z/horovod.git
fi
cd horovod
if [ -d dist ];then
rm -rf dist
fi
source /opt/rh/devtoolset-7/enable
python setup.py clean
HOROVOD_WITH_TENSORFLOW=1 python setup.py bdist
horovod_dir=`readlink -f build/lib.linux-*/horovod`
rm -rf $site_packages_dir/horovod*
cp -rp $horovod_dir $site_packages_dir/
cd dist
pwd
tar xzvf *tar.gz
cd -
horovod_bin_dir=`readlink -f build/scripts*`
fi
mkdir $work_dir/horovod/build/bin
cp `find |grep horovodrun` $work_dir/horovod/build/bin
echo "cp -rp ./$site_packages_dir/horovod* $site_packages_dir/"
cp -rp $work_dir/horovod/dist/$site_packages_dir/horovod* $site_packages_dir/
horovod_bin_dir=$work_dir/horovod/build/bin
}

function build_horovod_env()
Expand All @@ -72,11 +86,15 @@ function build_horovod_env()
build_horovod
}

function gen_horovod_env_file()
function gen_openmpi_env_file()
{
echo "export PATH=$python_dir:\$PATH">>horovod.env
echo "export PATH=$work_dir/openmpi-4.0.2/bin:\$PATH">>horovod.env
echo "export LD_LIBRARY_PATH=$work_dir/openmpi-4.0.2/lib:\$LD_LIBRARY_PATH">>horovod.env
}
function gen_horovod_env_file()
{
horovod_bin_dir=$work_dir/horovod/build/bin
echo "export PATH=$horovod_bin_dir:\$PATH">>horovod.env
}

Expand All @@ -93,8 +111,9 @@ function test()

function main()
{
gen_horovod_env_file
gen_openmpi_env_file
build_horovod_env
gen_horovod_env_file
test
}

Expand Down

0 comments on commit 95b5158

Please sign in to comment.