#!/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 `pwd`/single_process_pretrain.sh $dist_url
