Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert system variables to SBATCH

Tags:

slurm

sbatch

I would like to ask you if is possible to pass global system variables to #SBATCH tags.

I would like to do somethink like that

SBATCH FILE

#!/bin/bash -l
ARG=64.dat
NODES=4
TASK_PER_NODE=8
NP=$((NODES*TASK_PER_NODE))

#SBATCH -J 'MPI'+'_'+$NODES+'_'+$TASK_PER_NODE
#SBATCH -N $NODES
#SBATCH --ntasks-per-node=$TASK_PER_NODE

It isn't workink so that is why I ask you.

like image 842
Micchaleq Avatar asked Oct 22 '25 20:10

Micchaleq


1 Answers

Remember that SBATCH parameter lines are viewed by Bash as comments, so it will not try to interpret them at all.

Furthermore, the #SBATCH directives must be before any other Bash command for Slurm to handle them.

Alternatives include setting the parameters in the command line:

NODES=4 sbatch --nodes=$NODES ... submitscript.sh

or passing the submission script through stdin:

#!/bin/bash -l
ARG=64.dat
NODES=4
TASK_PER_NODE=8
NP=$((NODES*TASK_PER_NODE))

sbatch <<EOT
#SBATCH -J "MPI_$NODES_$TASK_PER_NODE"
#SBATCH -N $NODES
#SBATCH --ntasks-per-node=$TASK_PER_NODE

srun ...

EOT

In this later case, you will need to run the submission script rather than handing it to sbatch since it will run sbatch itself. Note also that string concatenation in Bash is not achieved with the + sign.

like image 193
damienfrancois Avatar answered Oct 26 '25 04:10

damienfrancois



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!