From 3f36f868c20df7b5171cba8ddbca1ed0e5ed0910 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Fri, 10 Jan 2025 12:26:49 +0100 Subject: [PATCH] feat: first half of auto selection between cpus-per-task and cpus-per-gpu - needs adjustment in jobstep executor code, too. --- snakemake_executor_plugin_slurm/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 85327a2..1d60361 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -291,7 +291,8 @@ def run_job(self, job: JobExecutorInterface): # fixes #40 - set ntasks regardless of mpi, because # SLURM v22.05 will require it for all jobs - if job.resources.get("gpus") or "gpu" in job.resources.get("gres", ""): + gpu_job = job.resources.get("gpus") or "gpu" in job.resources.get("gres", "") + if gpu_job: call += f" --ntasks-per-gpu={job.resources.get('tasks', 1)}" else call += f" --ntasks={job.resources.get('tasks', 1)}" @@ -305,8 +306,9 @@ def run_job(self, job: JobExecutorInterface): "specified. Assuming 'tasks_per_node=1'." "Probably not what you want." ) - - call += f" --cpus-per-task={get_cpus_per_task(job)}" + # we need to set cpus-per-task OR cpus-per-gpu, the function + # will return a string with the corresponding value + call += f" {get_cpus_per_task(job, gpu_job)}" if job.resources.get("slurm_extra"): self.check_slurm_extra(job)