@@ -155,14 +155,26 @@ def get_exec_mode(self) -> ExecMode:
155155 return ExecMode .REMOTE
156156
157157
158- def get_cpus_per_task (job : JobExecutorInterface ) :
159- cpus_per_task = job .threads
158+ def get_cpus_per_task (job : JobExecutorInterface , gpu : bool ) -> str :
159+ cpus_per_task = cpus_per_gpu = job .threads
160160 if job .resources .get ("cpus_per_task" ):
161+ cpus_per_task = job .resources .cpus_per_task
161162 if not isinstance (cpus_per_task , int ):
162163 raise WorkflowError (
163164 f"cpus_per_task must be an integer, but is { cpus_per_task } "
164165 )
165- cpus_per_task = job .resources .cpus_per_task
166- # ensure that at least 1 cpu is requested
167- # because 0 is not allowed by slurm
168- return max (1 , cpus_per_task )
166+ # ensure that at least 1 cpu is requested
167+ # because 0 is not allowed by slurm
168+ cpus_per_task = max (1 , job .resources .cpus_per_task )
169+ cpu_string = f"--cpus-per-task={ cpus_per_task } "
170+ elif gpu and job .resources .get ("cpus_per_gpu" ):
171+ cpus_per_gpu = job .resources .cpus_per_gpu
172+ if not isinstance (cpus_per_gpu , int ):
173+ raise WorkflowError (
174+ f"cpus_per_gpu must be an integer, but is { cpus_per_gpu } "
175+ )
176+ # ensure that at least 1 cpu is requested
177+ # because 0 is not allowed by slurm
178+ cpus_per_gpu = max (1 , job .resources .cpus_per_gpu )
179+ cpu_string = f"--cpus-per-gpu={ cpus_per_gpu } "
180+ return cpu_string
0 commit comments