使用 SLURM 和 MPI(4PY):无法分配请求的资源

Using SLURM and MPI(4PY): Cannot allocate requested resources

我的台式机上有一个 setup/installation SLURM,可以在将其部署到集群之前进行一些测试并了解它的工作原理。 台式计算机是 运行ning Ubuntu 18.10 (Cosmic),因为集群中的节点都在 运行ning 上。使用的 SLURM 版本是 17.11.9。 我已经测试了 SLURM 的一些功能,例如作业数组及其任务部署。 但是,我想与发送到集群中每个节点或 CPU 的不同任务进行通信,以便收集其结果(没有磁盘 I/O)。出于这个原因,我研究了如何管理它,例如消息队列和 MPI,或 OpenMPI。 (非常感谢任何其他实施策略,作为建议或建议。)

我用一个简单的 Python 片段测试了 MPI,开始了两个进程之间的通信。我正在使用 MPI4PY 来处理此通信。 此代码片段 运行 使用 mpiexec-command 没问题,但是 运行 通过 SLURM 和 sbatch-command 运行ning 它我无法让它工作。 SLURM 配置有 OpenMPI,opmi_info 声明支持 SLURM。

OpenMPI 版本 3.1.2-6(来自 dpkg -l | grep mpi) SLURM_VERSION 17.11.9 Ubuntu 18.10(宇宙) MPI4PY 版本 3.0.1。 (来自 pip 列表)

这是 Python3.6 代码片段:

    $cat mpi_test.py
    from mpi4py import MPI

    if __name__=='__main__':

      comm = MPI.COMM_WORLD
      rank = comm.Get_rank()

      if rank==0:
          data={'param1':1, 'param2':2, 'param3':3}        
          destinationNode = 1
          print('Im', rank, 'sending to ', destinationNode)
          comm.send(data, dest=destinationNode, tag=11)
      elif rank!=0:
          sourceNode = 0
          dataRx=comm.recv(source=sourceNode, tag=11)
          print('Im', rank, 'recieving from ', sourceNode)
          for keys in dataRx.keys():
              print('Data recieved: ',str(dataRx[keys]))

调用sbatch时使用的python.mpi.sbatch是:

    $cat python.mpi.sbatch
    #!/bin/bash -l
    #SBATCH --job-name=mpiSimpleExample
    #SBATCH --nodes=1
    #SBATCH --error=slurm-err-%j.err
    #SBATCH --export=all
    #SBATCH --time=0-00:05:00
    #SBATCH --partition=debug

    srun -N 1 mpiexec -n 2 python3 mpi_test.py
    #mpiexec -n 2 python3 mpi_test.py

    exit 0

运行 "sbatch python.mpi.sbatch" 使用此设置会产生以下输出:

    $sbatch python.mpi.sbatch
    $cat slurm-err-104.err 
    ----------------------------------------------------------------------
    There are not enough slots available in the system to satisfy the 2 
    slots
    that were requested by the application:
    python3

    Either request fewer slots for your application, or make more slots
    available for use.
    --------------------------------------------------------------------

修改 python.mpi.sbatch 以改为使用:

"srun -n 1 mpiexec -n 1 python3 mpi_test.py" 产生错误:

    $cat slurm-err-105.error
    Traceback (most recent call last):
      File "mpi_test.py", line 18, in <module>
        comm.send(data, dest=destinationNode, tag=11)
      File "mpi4py/MPI/Comm.pyx", line 1156, in mpi4py.MPI.Comm.send
      File "mpi4py/MPI/msgpickle.pxi", line 174, in mpi4py.MPI.PyMPI_send
        mpi4py.MPI.Exception: MPI_ERR_RANK: invalid rank
    ---------------------------------------------------------------------
    mpiexec detected that one or more processes exited with non-zero 
    status, thus causing the job to be terminated. The first process to do 
    so was:

    Process name: [[44366,1],0]
    Exit code:    1
    ---------------------------------------------------------------------

这是预期的,因为它仅从 1 个节点启动。

运行 mpi运行 主机名,产生四个机器实例,因此这台机器应该有四个插槽可用。 我可能 运行 Python3.6 最多有四个(修改 mpi_test.py 后)使用命令 "mpiexec -n 4 python3 mpi_test.py" 处理,并成功。

非常感谢任何帮助。

slurm.conf-文件:

# slurm.conf file generated by configurator.html.
# Put this file on all nodes of your cluster.
# See the slurm.conf man page for more information.
#
ControlMachine=desktop-comp
#ControlAddr=
#BackupController=
#BackupAddr=
#
AuthType=auth/munge
#CheckpointType=checkpoint/none
CryptoType=crypto/munge
#DisableRootJobs=NO
#EnforcePartLimits=NO
#Epilog=
#EpilogSlurmctld=
#FirstJobId=1
#MaxJobId=999999
#GresTypes=
#GroupUpdateForce=0
#GroupUpdateTime=600
#JobCheckpointDir=/var/slurm/checkpoint
#JobCredentialPrivateKey=
#JobCredentialPublicCertificate=
#JobFileAppend=0
#JobRequeue=1
#JobSubmitPlugins=1
#KillOnBadExit=0
#LaunchType=launch/slurm
#Licenses=foo*4,bar
#MailProg=/bin/mail
#MaxJobCount=5000
#MaxStepCount=40000
#MaxTasksPerNode=128
MpiDefault=openmpi
#MpiParams=ports=#-#
#PluginDir=
#PlugStackConfig=
#PrivateData=jobs
#ProctrackType=proctrack/cgroup
#Prolog=
#PrologFlags=
#PrologSlurmctld=
#PropagatePrioProcess=0
#PropagateResourceLimits=
#PropagateResourceLimitsExcept=
#RebootProgram=
ReturnToService=1
#SallocDefaultCommand=
SlurmctldPidFile=/var/run/slurm-llnl/slurmctld.pid
SlurmctldPort=6817
SlurmdPidFile=/var/run/slurm-llnl/slurmd.pid
SlurmdPort=6818
SlurmdSpoolDir=/var/lib/slurm-llnl/slurmd
SlurmUser=slurm
#SlurmdUser=root
#SrunEpilog=
#SrunProlog=
StateSaveLocation=/var/lib/slurm-llnl/slurmd
SwitchType=switch/none
#TaskEpilog=
#TaskPlugin=task/affinity
#TaskPluginParam=Sched
#TaskProlog=
#TopologyPlugin=topology/tree
#TmpFS=/tmp
#TrackWCKey=no
#TreeWidth=
#UnkillableStepProgram=
#UsePAM=0
#
#
# TIMERS
#BatchStartTimeout=10
#CompleteWait=0
#EpilogMsgTime=2000
#GetEnvTimeout=2
#HealthCheckInterval=0
#HealthCheckProgram=
InactiveLimit=0
KillWait=30
#MessageTimeout=10
#ResvOverRun=0
MinJobAge=300
#OverTimeLimit=0
SlurmctldTimeout=120
SlurmdTimeout=300
#UnkillableStepTimeout=60
#VSizeFactor=0
Waittime=0
#
#
# SCHEDULING
#DefMemPerCPU=0
FastSchedule=1
#MaxMemPerCPU=0
#SchedulerTimeSlice=30
SchedulerType=sched/backfill
SelectType=select/cons_res
SelectTypeParameters=CR_Core
#
#
# JOB PRIORITY
#PriorityFlags=
#PriorityType=priority/basic
#PriorityDecayHalfLife=
#PriorityCalcPeriod=
#PriorityFavorSmall=
#PriorityMaxAge=
#PriorityUsageResetPeriod=
#PriorityWeightAge=
#PriorityWeightFairshare=
#PriorityWeightJobSize=
#PriorityWeightPartition=
#PriorityWeightQOS=
#
#
# LOGGING AND ACCOUNTING
#AccountingStorageEnforce=0
#AccountingStorageHost=
#AccountingStorageLoc=
#AccountingStoragePass=
#AccountingStoragePort=
AccountingStorageType=accounting_storage/none
#AccountingStorageUser=
AccountingStoreJobComment=YES
ClusterName=cluster
#DebugFlags=
#JobCompHost=
#JobCompLoc=
#JobCompPass=
#JobCompPort=
JobCompType=jobcomp/none
#JobCompUser=
#JobContainerType=job_container/none
JobAcctGatherFrequency=30
JobAcctGatherType=jobacct_gather/none
SlurmctldDebug=3
#SlurmctldLogFile=
SlurmdDebug=3
#SlurmdLogFile=
#SlurmSchedLogFile=
#SlurmSchedLogLevel=
#
#
# POWER SAVE SUPPORT FOR IDLE NODES (optional)
#SuspendProgram=
#ResumeProgram=
#SuspendTimeout=
#ResumeTimeout=
#ResumeRate=
#SuspendExcNodes=
#SuspendExcParts=
#SuspendRate=
#SuspendTime=
#
#
# COMPUTE NODES
NodeName=desktop-comp CPUs=1 State=UNKNOWN
PartitionName=debug Nodes=desktop-compDefault=YES MaxTime=INFINITE State=UP

在您的更新问题中,您的 slurm.conf 行

NodeName=desktop-comp CPUs=1 State=UNKNOWN

这告诉 slurm 您的节点上只有一个 CPU 可用。您可以尝试 运行 slurmd -C 查看 slurm 在您的计算机上发现了什么,并将 CPUsCoresPerSocket 等值复制粘贴到您的 slurm.conf.