#!/bin/bash

#set -x
hostfile=./hostfile
num_node=$(cat $hostfile|sort|uniq |wc -l)
 
num_gpu=$(($num_node*4))
nodename=$(cat $hostfile |sed -n "1p")
dist_url=`echo $nodename | awk '{print $1}'`
echo $dist_url
rm `pwd`/hostfile-dl -f
cat $hostfile|sort|uniq >`pwd`/tmp
 
for i in `cat ./tmp`
do
    echo ${i} slots=4 >> `pwd`/hostfile-dl
done

mpirun -np ${num_gpu} --hostfile `pwd`/hostfile-dl --bind-to none -x LD_LIBRARY_PATH -x PATH `pwd`/ingle_process_pretrain2.sh $dist_url results
