[slurm-users] Getting nodes in a partition

Renat Yakupov renat at hawaii.edu
Fri May 18 02:12:36 MDT 2018


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> 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 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?
>
>
>
> Regards,
> Mahmood
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schedmd.com/pipermail/slurm-users/attachments/20180518/efc94033/attachment.html>


More information about the slurm-users mailing list