To achieve your goal—running 3 independent tasks with 2 CPUs each, but allowing tasks to start as soon as 2 CPUs are available (rather than waiting for all 6 CPUs to be free)—you need to avoid over-subscribing the node while still allowing task packing.
--ntasks-per-node and --cpus-per-task with --wait=0By default, srun waits for all requested resources to be available before launching any tasks. To allow tasks to start as soon as their required CPUs are free, use the --wait=0 flag (or --no-kill if you want to ensure tasks don't get killed if resources are reallocated).
However, the most reliable way is to submit each task separately or use job arrays with resource constraints per task.
Run each task as a separate srun command, each requesting 2 CPUs:
bashsrun --cpus-per-task=2 bash -c 'echo $SLURM_PROCID' & srun --cpus-per-task=2 bash -c 'echo $SLURM_PROCID' & srun --cpus-per-task=2 bash -c 'echo $SLURM_PROCID' & wait
srun will start as soon as 2 CPUs are free.& runs them in the background, and wait ensures the script waits for all to finish.If you want to manage them as a single job, use a job array with --array:
bashsbatch --array=1-3 --cpus-per-task=2 --wrap="bash -c 'echo \$SLURM_ARRAY_TASK_ID'"
--ntasks-per-node with --overcommitIf you want to force Slurm to pack tasks onto the node (even if it risks oversubscription), use:
bashsrun --cpus-per-task=2 --ntasks=3 --overcommit bash -c 'echo $SLURM_PROCID'
srun or job arrays).--overcommit), but be aware of oversubscription risks.Would you like help testing or refining one of these approaches?
Vibe can make mistakes. Check answers. Learn more