Search code examples
mpidistributed-computinghpcslurm

Running correctly a Slurm script with more nodes and less cores


Each single node of the hpc has a maximum possible number of cores equal to 24 but they are not often all available so I'd like to run the code on 4 nodes with 20 cores each one (instead of 24).

Is it correct this using of MPI?

#!/bin/sh
#
# Replace <ACCOUNT> with your account name before submitting.
#
#SBATCH --account=aaa            # The account name for the job.
#SBATCH --job-name=job_name      # The job name.
#SBATCH -N 4                     # The number of nodes to use
                                 # (note there are 24 cores per node)
#SBATCH --exclusive
#SBATCH --time=23:58:00          # The time the job will take to run.

source activate env_python
mpirun -n 80 python script.py

# End of script

Solution

  • This would do what you want:

    #!/bin/sh
    #
    # Replace <ACCOUNT> with your account name before submitting.
    #
    #SBATCH --account=aaa            # The account name for the job.
    #SBATCH --job-name=job_name      # The job name.
    #SBATCH -N 4                     # The number of nodes to use
                                     # (note there are 24 cores per node)
    #SBATCH --tasks-per-node=20
    #SBATCH --time=23:58:00          # The time the job will take to run.
    
    source activate env_python
    mpirun -n 80 python script.py
    
    # End of script
    

    Requesting 4 nodes with 20 tasks each, which will be mapped to the 80 MPI Ranks. The -n 80 is not necessary then.