Skip to main content

Interactive Slurm Jobs

Interactive resources can be requested from Slurm through the srun command.

srun --partition=<partition> --nodes=<compute node> --ntasks=<task> --cpus-per-task <cores> --mem <size> --time <time> --pty /bin/bash

For example, the following command requests 4 cpus from 1 node in the “cmp” partition with 8G of memory to run a single task for a period of at most 4 hours. The combination of the -pty flag and /bin/bash command indicates that slurm should run a bash shell in pseudo terminal node. (see Partitions and Queues in the next section for more information on partitions.)

srun --partition=cmp --nodes 1 --ntasks 1 --cpus-per-task 4 --mem=32G --time 0-04:00:00 --pty /bin/bash

Shorthand abbreviations exists for the options. The following is equivalent to the above command:

srun -p cmp -N 1 -n 1 -c 4 --mem 32G -t 0-4 --pty /bin/bash

If the resources are available, the command starts an interactive session and the user is connected using ssh to the assigned compute node. If the resources are unavailable, the command will stall until the resources become available.

Resources obtained in an interactive job remain accessible to the user as long as the interactive session remains active. The user is able to open additional terminal sessions on the assigned nodes using ssh. When the interactive session is closed, the requested resources are released, and the user will no longer have access to the allocated nodes.