PySlurm / pyslurm

Python Interface to Slurm
https://pyslurm.github.io
GNU General Public License v2.0
474 stars 116 forks source link

sbatch options support #247

Closed mperryatos closed 1 year ago

mperryatos commented 1 year ago

Is there a list of sbatch options supported in the latest version of Pyslurm, for Slurm version 22.05? I am particularly interested in the option --gres. This option does not appear to be supported. If that is correct, is support for --gres planned for a future version? The Pyslurm documentation does not appear to have been updated since 2019. Thanks.

tazend commented 1 year ago

Hi @mperryatos

I think the list of options from the documentation could still be accurate, because mostly during the last major updates the code was just ported to work with the newest version, but rarely new sbatch options were added (if there were any to be added)

The actual list of options could be found in the code itself: https://github.com/PySlurm/pyslurm/blob/main/pyslurm/pyslurm.pyx#L2346 But yeah, that is a bit of a hassle actually - particularly because the option names there do not always match with the sbatch names, but rather with the names that are used in the slurm header files.

Therefore you won't see the gres option sbatch uses verbatim there, because it is covered under a different name: tres_per_node (https://github.com/PySlurm/pyslurm/blob/main/pyslurm/pyslurm.pyx#L2684) If you want to request a GPU with a specific model, you need to do it like this for example:

options = { "tres_per_node": "gres:gpu:tesla:1"}

The "gres:" identifier is usually added by sbatch internally, but here it isn't so one needs to specify it. I hope that works.

Alternatively, I am currently reworking the Job retrieval/submission API: https://github.com/PySlurm/pyslurm/issues/224 That branch is for 22.05 so you could try it out (but it's still work in progress, so bugs are expected :) ) The equivalent to sbatch's "gres" option there would be "gres_per_node":

from pyslurm import JobSubmitDescription
job_desc = JobSubmitDescription()

job_desc.gres_per_node = {"gpu:tesla": 2, "gpu:volta": 3}
... other options ...

job_desc.submit()

Documentation of that option visible in python with: help(JobSubmitDescription.gres_per_node) for example.

Hope that helps :)

mperryatos commented 1 year ago

Thanks for the quick response. It sounds like tres_per_node will do what I need. I'll try it out.