Search code examples
slurmhpc

Slurm Scripts and Assigning Number of Cores


So I've started looking at some basic HPC topics. However, I have one very basic problem: How do I assign the correct (or desired) number of cores within a slurm script?

I appreciate this is a rather basic question but I can't find anything online or in text books that helps me overcome the problem. Image of a section of the slurm script:enter image description here

Any help is very appreciated.


Solution

  • In the fragment you have shown, it has the options

    #SBATCH --ntasks=1
    #SBATCH --cpus-per-task=1
    

    This means that (as far as Slurm is concerned) you will be launching 1 process (--ntasks=1) that has access to 1 cores-worth of resource (-cpus-per-task=1). How that process is bound to cores is a slightly different question, but on most HPC systems this would usually mean that the scheduler would assign you 1 physical core for your process.

    However, you also have in your fragment:

    #SBATCH --exclusive
    #SBATCH --nodes=1
    

    These options generally mean that you are asking for exclusive access to a single node (i.e. only your job is allowed to run on it). For example, if the nodes on the HPC system you are using have 64 physical cores; then, as it stands, this example fragment would ask for a whole node for your use (64 cores) but then specify that you only want to use 1 of them (from --ntasks=1 and -cpus-per-task=1).

    If you wanted to change this to ask for 32 processes running on 32 cores on 1 node with exclusive access, you would use something like:

    #SBATCH --ntasks=32
    #SBATCH --cpus-per-task=1
    #SBATCH --exclusive
    #SBATCH --nodes=1