[slurm-users] Getting nodes in a partition

Ole Holm Nielsen Ole.H.Nielsen at fysik.dtu.dk
Fri May 18 02:40:18 MDT 2018


Hi,

It seems to me that the sinfo command is the simplest solution to 
listing hosts in a partition.  Here is an example:

# sinfo -N -p xeon8_48
NODELIST   NODES PARTITION STATE
d001           1  xeon8_48 idle
d002           1  xeon8_48 idle
d003           1  xeon8_48 idle
d004           1  xeon8_48 idle
d005           1  xeon8_48 idle
d006           1  xeon8_48 idle
d007           1  xeon8_48 idle
d008           1  xeon8_48 idle
d009           1  xeon8_48 idle
d010           1  xeon8_48 idle
d011           1  xeon8_48 idle
d012           1  xeon8_48 idle
d013           1  xeon8_48 idle
d014           1  xeon8_48 idle
d015           1  xeon8_48 idle
d016           1  xeon8_48 idle
d017           1  xeon8_48 idle
d018           1  xeon8_48 idle
d019           1  xeon8_48 idle
d020           1  xeon8_48 idle
d021           1  xeon8_48 idle
d022           1  xeon8_48 idle

The output of sinfo can be formatted in many ways, please see the man-page.

I have some remarks on host lists in my Wiki page 
https://wiki.fysik.dtu.dk/niflheim/SLURM#expanding-and-collapsing-host-lists

/Ole

On 05/18/2018 10:12 AM, Renat Yakupov wrote:
> Hi Mahmood,
> 
> I needed something similar and here is what I was suggested to do. You 
> need to further modify the node list to be bash-friendly using 
> curly-bracketed ranges:
> 
> MYPART=debug
> NODES=`scontrol show partition $MYPART | grep -w Nodes | cut -d '=' -f 2 
> | sed -r -e 's:[[](.*)[]]:{\1}:' -e 's:([0-9]+)[-]([0-9]+):{\1..\2}:g' | 
> tr -s {}`
> echo $NODES
>      cluster-{105..120}
> eval echo $NODES
>      cluster-105 cluster-106 cluster-107 cluster-108 cluster-109 
> cluster-110 cluster-111 cluster-112 cluster-113 cluster-114 cluster-115 
> cluster-116 cluster-117 cluster-118 cluster-119 cluster-120
> 
> It doesnt work if you have comma separated node lists, e.g. 
> cluster-[105-121],cluster-[125-140], but it does work for comma 
> separated ranges, e.g. cluster-[109,115-116,118-121,130,138]. In the 
> former case, you can split the node lists into two or more, and do the 
> conversion for each sub-list.
> 
> Best regards,
> Renat.
> 
> On 18 May 2018 at 09:11, Mahmood Naderan <mahmood.nt at gmail.com 
> <mailto:mahmood.nt at gmail.com>> wrote:
> 
>     Hi,> 
> 
> 
>     Regards,
>     Mahmood
> 
> 
-- 
Ole Holm Nielsen
PhD, Senior HPC Officer
Department of Physics, Technical University of Denmark,
Building 307, DK-2800 Kongens Lyngby, Denmark
E-mail: Ole.H.Nielsen at fysik.dtu.dk
Homepage: http://dcwww.fysik.dtu.dk/~ohnielse/
Tel: (+45) 4525 3187 / Mobile (+45) 5180 1620
>     Is there any slurm variable to read the node names of a partition?
>     There is an MPI option --hostfile  which we can write the node names.
>     I want to use something like this in the sbatch script:
> 
> 
>     #SBATCH --partition=MYPART
>     ... --hostfile $SLURM_NODES_IN_PARTITION ....
> 
>     I can manually manipulate the output of scontrol to extract node
>     names. Like this:
> 
>     [mahmood at rocks7 ~]$ scontrol show partition MYPART | grep -w Nodes |
>     cut -d '=' -f 2
>     compute-0-[4-6]
> 
>     But that basically is not
>     compute-0-4
>     compute-0-5
>     compute-0-6
> 
>     Which I have to post process more. Any better idea?



More information about the slurm-users mailing list