Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Renat Yakupov
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  wrote:

> Hi,
> 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@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?
>
>
>
> Regards,
> Mahmood
>
>


Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Marcus Wagner

Hi Mahmood,

slurm comes with hostlist extraction:

[mahmood@rocks7 ~]$ scontrol show hostnames $(scontrol show partition MYPART | 
grep -w Nodes | cut -d '=' -f 2)


This would then be

compute-0-4
compute-0-5
compute-0-6


Best
Marcus

On 05/18/2018 09:11 AM, Mahmood Naderan wrote:

Hi,
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@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?



Regards,
Mahmood



--
Marcus Wagner, Dipl.-Inf.

IT Center
Abteilung: Systeme und Betrieb
RWTH Aachen University
Seffenter Weg 23
52074 Aachen
Tel: +49 241 80-24383
Fax: +49 241 80-624383
wag...@itc.rwth-aachen.de
www.itc.rwth-aachen.de




Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread SLIM, HENK A.
Does

sinfo -h -O nodehost -p partition | sort

help?

Also 

scontrol show hostname nodelist

where nodelist is compute-0-\[4-6\]

would work.

Regards

Henk


-Original Message-
From: slurm-users  On Behalf Of Mahmood 
Naderan
Sent: 18 May 2018 08:12
To: Slurm User Community List 
Subject: [slurm-users] Getting nodes in a partition

Hi,
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@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?



Regards,
Mahmood



Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Ole Holm Nielsen

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 > 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.niel...@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@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?




Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Mahmood Naderan
>slurm comes with hostlist extraction:
>
>[mahmood@rocks7 ~]$ scontrol show hostnames $(scontrol show partition MYPART | 
>grep -w Nodes | cut -d '=' -f 2)


Excellent. That works. Many thanks...


I wrote the following method before that!

[mahmood@rocks7 ~]$ cat nodes.sh
#!/bin/bash
NAMES=`scontrol show partition NOLIMIT | grep -w Nodes | cut -d '=' -f 2`
echo $NAMES
BASENAME=`echo $NAMES | cut -d '[' -f 1`
RANGE=`echo $NAMES | cut -d '[' -f2 | cut -d ']' -f1`
START=`echo $RANGE | cut -d '-' -f1`
END=`echo $RANGE | cut -d '-' -f2`
for (( i=$START; i <= $END; i++ )); do
  echo "$BASENAME$i"
done
[mahmood@rocks7 ~]$ ./nodes.sh
compute-0-[4-6]
compute-0-4
compute-0-5
compute-0-6




Regards,
Mahmood



Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Mahmood Naderan
>Does
>
>sinfo -h -O nodehost -p partition | sort
>
>help?

Yes that also works. Thanks Henk.

Regards,
Mahmood



Re: [slurm-users] Getting nodes in a partition

2018-05-18 Thread Brian Andrus
I saw you got some good answers, but a quick note on mpi. For some of 
them, you are compiling it yourself, they can be "slurm-aware" (eg: 
openmpi). Then when you do 'mpirun' it automatically knows your 
inherited hostlist and you need do nothing extra when running.


Brian Andrus


On 5/18/2018 12:11 AM, Mahmood Naderan wrote:

Hi,
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@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?



Regards,
Mahmood