Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically rerun jobs submitted with sbatch --array upon error

Tags:

slurm

sbatch

I am submitting jobs in an array. Occasionally one job will error because of a difficult to diagnose gpu memory issue. Simply rerunning the job results in success.

What I would like to do is catch this error, log it, and put the job back into slurm's queue to be rerun. If this is not possible to do with an array job, that's fine, it's not essential to use arrays (though it is preferred).

I've tried playing around with sbatch --rerun, but this doesn't seem to do what I want (I think this option is for rerunning after a hardware error detected by slurm, or a node is restarted when a job is running - this isn't the case for my jobs).

Any advice well received.

like image 958
James Owers Avatar asked Oct 29 '25 00:10

James Owers


1 Answers

If you can detect the GPU memory issue, you can end your submission job with a construct like this:

if <gpu memory issue>; then
    scontrol requeue $SLURM_JOBID
fi

This will put the job back in the scheduling queue and it will be restarted as is. Interestingly, the SLURM_RESTART_COUNT environment variable holds the number of times the job was re-queued.

like image 181
damienfrancois Avatar answered Nov 01 '25 13:11

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!