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

时间:2019-06-10 08:19:44

标签: python-3.x mpi openmpi slurm mpi4py

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

我已经用一个简单的Python代码段测试了MPI,开始了两个进程之间的通信。我正在使用MPI4PY处理此通信。 此代码段可以通过mpiexec-command正常运行,但是通过SLURM和sbatch-command运行时,我无法正常运行。 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。 (来自点子列表)

这是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个节点开始。

运行mpirun主机名将产生该计算机的四个实例,因此该计算机应具有四个可用插槽。 我可以使用命令“ mpiexec -n 4 python3 mpi_test.py”成功运行多达四个(修改mpi_test.py之后)进程的Python3.6。

非常感谢您的帮助。

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

1 个答案:

答案 0 :(得分:2)

在更新问题中,您在slurm.conf中包含该行

NodeName=desktop-comp CPUs=1 State=UNKNOWN

这告诉Slurm您的节点上只有一个CPU可用。您可以尝试运行slurmd -C来查看Slurm发现的有关您计算机的内容,并将CPUsCoresPerSocket等值粘贴到slurm.conf中。