문제

나는 slurm 자원 관리 소프트웨어를 사용하여 클러스터에서 openmpi로 실행 파일을 실행하고 있습니다. 나는 각 노드에 대해 프로세스 수가 다를 수있는 각 노드에 얼마나 많은 프로세스를 할당 해야하는지를 지정하는 방법을 찾고 싶습니다.

내가 찾는 것을 명확히하기위한 예 : 3 개의 노드에서 7 개의 프로세스를 실행하고 싶다고 가정 해보십시오. 그런 다음 다음과 같이 말할 수 있기를 원합니다. 노드 1은 나머지 프로세스 중 각각 3을 실행하도록 노드 2 및 3 등급으로 프로세스를 실행해야합니다.

나는 모든 노드가 사용하고있는 클러스터에서 모든 노드가 동일하기 때문에 실제 노드가 노드 1인지 상관하지 않습니다. 또한 Slurm에 의해 할당 될 노드가 어떤 노드를 할당할지 모르므로 노드 파일에서 노드의 이름을 하드 코드로 보낼 수 없습니다. 내가 발견 한 OpenMPI 문서의 예는 예제를 위해 이와 같은 호스트 파일을 정의합니다.

aa slots=1
bb slots=3
cc slots=3
.

그러나 나는이 접근법에 두 가지 문제가있다 :

  1. PRIENI의 이름을 알지 못합니다. 노드의 AA, BB, CC.
  2. 내가 그들을 알게 되더라도 노드 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
.

그것은 조금 못생긴 것입니다.그리고 아마도 "slot= 0-7"은 "7"하드 코딩되어 있지 않아야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top