← 返回命令列表

Linux command

srun 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Submit

srun --pty /bin/bash

Submit

srun --ntasks-per-node [num_cores] --mem-per-cpu [memory_MB] --pty /bin/bash

Run

srun -p [partition_name] -t [HH:MM:SS] [command]

Run

srun --gpus=[num_gpus] --pty /bin/bash

Run

srun -n [num_tasks] -c [cpus_per_task] [command]

Connect

srun --jobid [job_id] --pty /bin/bash

说明

srun submits a job for execution or initiates job steps in real time. For interactive work, it creates an interactive session on compute nodes. It can also be used within batch scripts to launch parallel tasks. The command handles resource allocation automatically, requesting nodes from the scheduler and launching the specified program across allocated resources.

参数

--pty
Execute in pseudo-terminal mode (for interactive use)
--jobid _id_
Initiate a job step under an already allocated job
-n, --ntasks _number_
Number of tasks to run
--ntasks-per-node _ntasks_
Number of tasks to invoke on each node
-c, --cpus-per-task _ncpus_
Number of CPUs allocated per task
--mem _sizeunits_
Memory required per node (default units: MB; supports K, M, G, T)
--mem-per-cpu _sizeunits_
Minimum memory required per usable allocated CPU
-p, --partition _name_
Request specific partition for resource allocation
-N, --nodes _min-max_
Number of nodes required (optionally a range)
-t, --time _time_
Time limit for job (format: HH:MM:SS or days-HH:MM:SS)
-J, --job-name _name_
Specify a name for the job
-G, --gpus _type:number_
Total number of GPUs required for the job
--gres _list_
Comma-delimited list of generic consumable resources (e.g., gpu:2)
-w, --nodelist _node_list_
Request a specific list of hosts
-x, --exclude _host_list_
Exclude specific hosts from the allocation
-o, --output _filename_
Redirect standard output to specified file
-e, --error _filename_
Redirect standard error to specified file
-D, --chdir _path_
Change to specified directory before execution
--exclusive
Job cannot share nodes with other running jobs
--export _{ALL|NONE|variables}_
Control which environment variables are propagated to the job
--mpi _type_
Identify the type of MPI to be used

FAQ

What is the srun command used for?

srun submits a job for execution or initiates job steps in real time. For interactive work, it creates an interactive session on compute nodes. It can also be used within batch scripts to launch parallel tasks. The command handles resource allocation automatically, requesting nodes from the scheduler and launching the specified program across allocated resources.

How do I run a basic srun example?

Run `srun --pty /bin/bash` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --pty do in srun?

Execute in pseudo-terminal mode (for interactive use)