Skip to content

Commit 53ac8b0

Browse files
authored
fix: allow unsetting of tasks for gpu jobs (#318)
this PR should fix #316 - python's process management seems to interfere with SLURM tasks under unknown circumstances. Unsetting the tasks per gpu might be a solution. If a user defined `tasks` <= 0, the `--ntasks-per-gpu` flag is not issued. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for a new resource key to control the number of tasks per GPU in SLURM job submissions. * **Bug Fixes** * Improved handling of SLURM `--ntasks-per-gpu` and `--ntasks` options, allowing greater flexibility and correct omission when appropriate. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 6d7c50a commit 53ac8b0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

snakemake_executor_plugin_slurm/submit_string.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ def get_submit_command(job, params):
5050
if job.resources.get("nodes", False):
5151
call += f" --nodes={job.resources.get('nodes', 1)}"
5252

53-
# fixes #40 - set ntasks regardless of mpi, because
54-
# SLURM v22.05 will require it for all jobs
5553
gpu_job = job.resources.get("gpu") or "gpu" in job.resources.get("gres", "")
5654
if gpu_job:
57-
call += f" --ntasks-per-gpu={job.resources.get('tasks', 1)}"
55+
# fixes #316 - allow unsetting of tasks per gpu
56+
# apparently, python's internal process manangement interfers with SLURM
57+
# e.g. for pytorch
58+
ntasks_per_gpu = job.resources.get(
59+
"tasks_per_gpu", job.resources.get("tasks", 1)
60+
)
61+
if ntasks_per_gpu >= 1:
62+
call += f" --ntasks-per-gpu={ntasks_per_gpu}"
5863
else:
64+
# fixes #40 - set ntasks regardless of mpi, because
65+
# SLURM v22.05 will require it for all jobs
5966
call += f" --ntasks={job.resources.get('tasks', 1)}"
6067

6168
# we need to set cpus-per-task OR cpus-per-gpu, the function

0 commit comments

Comments
 (0)