To achieve your goal—running two independent tasks on a Slurm node with only 2 CPU cores, but allowing one task to start immediately if only 1 core is available—you need to adjust your resource request to avoid the strict "all-or-nothing" behavior of --cpus-per-task and --ntasks.
Your command:
bashsrun --cpus-per-task=1 --ntasks=2 bash -c 'echo $SLURM_PROCID'
--ntasks-per-coreTo allow one task to start immediately if only 1 core is available, use:
bashsrun --ntasks=2 --cpus-per-task=1 --ntasks-per-core=1 bash -c 'echo $SLURM_PROCID'
--ntasks-per-core=1 tells Slurm to pack tasks as tightly as possible on available cores.--overcommitIf you want to force Slurm to start tasks even if resources are oversubscribed (not recommended for CPU-bound tasks, but useful for I/O-bound or lightweight tasks):
bashsrun --ntasks=2 --cpus-per-task=1 --overcommit bash -c 'echo $SLURM_PROCID'
--overcommit allows Slurm to ignore strict resource limits and start tasks immediately, even if it means oversubscribing cores.--ntasks-per-core=1--overcommitRecommendation: Use --ntasks-per-core=1 for your case. It respects Slurm's resource management while allowing tasks to start as soon as cores are free.
Vibe can make mistakes. Check answers. Learn more