OpenMPIを用いたノード間のプロセスの非均一分布
-
21-12-2019 - |
質問
slurm リソース管理ソフトウェアを使用して、クラスタ上のOpenMPIで実行可能ファイルを実行しています。各ノードにどのようなプロセスを割り当てるかを指定する方法を見つけたいと思います。ここで、各ノードごとにプロセス数が異なる場合があります。
私が探しているものを明確にするための例:3ノードで7つのプロセスを実行したいとします。それから私は次のようなことを言うことができるようになりたいです。 ノード1は、ランクN、ノード2、および3のプロセスを実行する必要があります。
私はどの物理ノードがノード1であるかを注意していますが、すべてのノードは私が使用しているクラスタで等しいので。また、私はスラムによって割り当てられるノードがどのノードであるか知りませんので、ホストファイルのノードの名前をハードコーディングすることはできません。私が見つけたOpenMPI文書の例は、このようなホストファイルを定義します。
aa slots=1
bb slots=3
cc slots=3
.
しかし、このアプローチには2つの問題があります:
- 私は、ノードの名前AA、BB、CCの先験的を知りません。
- 私がそれらを知っていても、ノードAAのプロセスは必ずしも正しいランクを持っていません。
解決
HRISTO ILIEVのコメントのおかげで、私は質問に記載されている例の解決策を見つけました:
#!/bin/bash
HOSTFILE=./myHostfile
RANKFILE=./myRankfile
# Write the names of the nodes allocated by SLURM to a file
scontrol show hostname ${SLURM_NODELIST} > $HOSTFILE
# Number of processes
numProcs=7
# Number of nodes
numNodes=${SLURM_JOB_NUM_NODES}
# Counts the number of processes already assigned
count=0
while read p; do
# Write the node names to a rank file
if [ $count == 0 ]
then
echo "rank $count=$p slot=0-7" > $RANKFILE
let count=$count+1
let numNodes=$numNodes-1 # Number of nodes that are still available
else
# Compute the number of processes that should be assigned to this node
# by dividing the number of processes that still need to be assigned by
# the number of nodes that are still available. (This automatically "floor"s the result.)
let numProcsNode=($numProcs-$count)/$numNodes
for i in `seq 1 $numProcsNode`
do
echo "rank $count=$p slot=0-7" >> $RANKFILE
let count=$count+1
done
let numNodes=$numNodes-1 # Number of nodes that are still available
fi
done < $HOSTFILE
mpirun --display-map -np $numProcs -rf $RANKFILE hostname
.
それは少し醜いです。そしておそらく「スロット= 0-7」は「7」を持つべきではありません。
所属していません StackOverflow