[slurm-users] Slurm commands for launching tasks: salloc and sbatch

Loris Bennett loris.bennett at fu-berlin.de
Tue Jul 4 13:09:32 UTC 2023


Mike Mikailov <mmikailov at gmail.com> writes:

> They should not affect the task performance.
>
> May be the cluster configuration allocated slow machines for salloc. 
>
> salloc and sbatch have different purposes:
>
> * salloc is used to allocate a set of resources to a job. Once the resources have been allocated, the user can run a command or script on the allocated
>  resources.
> * sbatch is used to submit a batch script to Slurm. The batch script contains a list of commands or scripts that will be executed on the allocated
>  resources.
>
> In general, salloc is used for jobs that need to be run interactively, such as jobs that require a shell or jobs that need to be debugged. sbatch is used
> for jobs that can be run in the background, such as long-running jobs or jobs that are submitted by a queuing system.
>
> Here is a table that summarizes the key differences between salloc and sbatch:
>
>  Feature  salloc  sbatch  
>  Purpose  Allocate resources and run a command or script  Submit a batch script  
>  Interactive  Yes  No  
>  Background  No  Yes  
>  Queuing system  No  Yes  

I am not sure what you mean with the last point, since 'salloc' is also
handled by the queueing system.  If the resources requested are
currently not available, 'salloc' will wait until they are.

Cheers,

Loris

> Here are some examples of how to use salloc and sbatch:
>
> * To allocate 2 nodes with 4 CPUs each and run the command ls, you would use the following command:
>
> Code snippet
> salloc -N 2 -c 4 ls
>
> * To submit a batch script called my_job.sh that contains the command python my_script.py, you would use the following command:
>
> Code snippet
> sbatch my_job.sh
>
> For more information on salloc and sbatch, please see the following documentation:
>
> * salloc documentation: https://slurm.schedmd.com/salloc.html
> * sbatch documentation: https://slurm.schedmd.com/sbatch.html
>
> Sent from my iPhone
>
>  On Jul 4, 2023, at 8:22 AM, Татьяна Озерова <tanyaozerova1318 at gmail.com> wrote:
>
>  Hello! I have question about way of launching tasks in Slurm. I use the service in cloud and submit an application with sbatch or salloc. As far as I
>  am concerned, the commands are similar: they allocate resources for counting users tasks and run them. However, I have received different
>  results in cluster performance for the same task (task execution time is too long in case of salloc). So my question is what is the difference
>  between these two commands, that can affect on task performance? Thank you beforehand.
>
-- 
Dr. Loris Bennett (Herr/Mr)
ZEDAT, Freie Universität Berlin



More information about the slurm-users mailing list