Using srun

Interactive Jobs can be invoked directly using the srun command. Since srun is not a part of a sbatch script here, additional parameters need to be supplied.

srun --partition=epyc --mem=4G --time=1-0 --pty

The commandline options of srun  are mostly identical to sbatch , consult man srun for more details.

Serial Jobs (1 CPU core)

By default, one task with one CPU is started.

This is how it looks like:

RZBK@licca001:~$ srun --partition=epyc --mem=4G --time=1-0 --pty bash
RZBK@licca002:~$

Note that this hostname of the bash-prompt has changed from licca001  (the Login-Node) to licca002 (a Compute-Node).

Keeping your interactive job alive using tmux

Any interactive job will die as soon as your SSH-connection to the login nodes is interrupted, no matter if it was intentionally or unintentionally (i.e. connection problems, Wifi, etc.). To prevent this from happening, the use of a terminal multiplexer is recommended, see Keeping your (interactive) session alive.

Parallel Jobs

If you need more than one CPU core using multithreading (i.e. OpenMP or posix-threads), MPI-parallelization or even a combination of both, you need to set the corresponding options to also allocate these ressources. These options are:

  • --cpus-per-task for interactive multithreaded Jobs
  • --ntasks OR --ntasks-per-node AND --nodes for interactive MPI-parallelized Jobs.

For multithreading it is necessary to set the environment variable OMP_NUM_THREADS manually after starting an interactive Job using:

Using SLURM environment variables
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK

or

Explicit
export OMP_NUM_THREADS=4

Failure to set this variable properly will result in inefficient Jobs.

GPU Jobs

The following starts an interactive GPU job using 1 CPU core and 1 GPU:

RZBK@licca001:~$ srun --partition=epyc-gpu --gpus=1 --mem=4G --time=1-0 --pty bash
RZBK@licca047:~$

If your code benefits from both GPUs and multiple CPU cores, then additional CPU cores should be requested as well, see Parallel Jobs.

Keeping your (interactive) session(s) alive

Use a terminal multiplexer on the Login Node to keep any session alive even if your SSH disconnects vor various reasons. We recommend using tmux .

Before starting any calculations or submitting any interactive Job, start a new tmux session simply by typing tmux in the command prompt. A green bar in the bottom will appear in the bottom of your window. Then continue as usual.

[0] is the session index key (the session may be renamed to any string though), followed by one or multiple windows in the format window-index:active-command , here we are just running the bash-Shell in the Window with index 0 (the window itself may be renamed, replacing the active-command, but the index cannot). The asterisk indicates the currently active window.

In the event your SSH client disconnects, simply re-attach to the previously active session by reestablishing your SSH connection and entering on the command line:

tmux attach

or attach to a specific session:

tmux list-session
tmux attach -t $session_index_key

To purposely disconnect while keeping the session alive, simply press the prefix key CTRL-b (pressing b while holding down the CTRL key) and followed by d to detach the session. You may close your SSH-connection now.

Most tmux commands can only be used with the prefix key. To get a list for all tmux commands use CTRL+b and ?  or check out a popular Cheat-Sheet.

The most notable difference between a regular session and a tmux-session is the fact that you cannot scroll with your mouse wheel. To see the contents above the screen you need to enter COPY mode. Most commonly this is done with CTRL-b and the PageUp key (immediately scrolls one page up). You can even seach up in COPY mode by hitting ? (without prefix key), then type a string and hit return. Jump (up) to the next search result using the n key (N in reverse). To exit COPY mode press q.

Some other basic tmux commands (all to be prefixed by CTRL-b):

CommandDescription
ddetach session
wlist sessions and windows (select by using arrow keys and press RETURN)
copen a new window
0-9Jump to window with index 0-9
$rename session
,rename window
ngo to next window
pgo to previous window
&kill a window (you will need to confirm)