Interactive Jobs

Interactive Jobs

Note: Interactive jobs let you run commands directly on a compute node, useful for testing, debugging, or running short tasks.

What Interactive Jobs Do

Instead of submitting a batch script, interactive jobs give you a live shell on a compute node. This lets you try commands, load modules, and run programs in real time.

Important: Interactive sessions started with srun --pty bash cannot run GUI applications. If you need to run a GUI on a compute node, use salloc to allocate the node, then ssh -X to connect to it. Find the node name using squeue or the $SLURM_JOB_NODELIST environment variable.

Starting an Interactive Job

Use the srun command with --pty bash to open an interactive session:

srun -p queue_name --pty bash

Replace queue_name with the partition you want (e.g., short-40core, gpu).

Requesting Resources

You can specify resources just like in batch jobs. Here are common examples:

Basic Interactive Session

srun -p short-40core --pty bash

Opens a shell on the short-40core partition with default resources.

Full Node with Time Limit

srun -p short-40core -N 1 -n 40 --time=01:00:00 --pty bash

Requests one node with 40 cores and a 1-hour time limit.

Specific Memory

srun -p short-40core-shared -N 1 -n 10 --mem=32GB --time=02:00:00 --pty bash

Requests 10 cores and 32GB of memory for 2 hours on a shared partition.

Note: Specific memory requests with --mem are only required for shared partitions like short-40core-shared. On exclusive partitions, you get all available memory on the node by default.

GPU Interactive Session

srun -p a100 --gres=gpu:1 --time=01:00:00 --pty bash

Requests one GPU on the a100 partition for 1 hour.

Common Interactive Session Options

Option Purpose Example
-p Partition/queue -p short-40core
-N Number of nodes -N 1
-n Number of tasks/cores -n 20
--mem Memory per node --mem=64GB
--time Time limit (HH:MM:SS) --time=02:00:00
--gres Generic resources (GPU) --gres=gpu:1
--pty bash Open interactive shell Always at end of command

Working in an Interactive Session

Once your interactive job starts, you'll have a shell prompt on the compute node. You can:

Load Modules

module load anaconda/3
conda activate my-env

Compile Code

gcc -o myprogram myprogram.c

Run Programs

./myprogram
python script.py

Test MPI or OpenMP

export OMP_NUM_THREADS=20
./my_openmp_program

mpirun -np 40 ./my_mpi_program

Exit and Release

When finished, type exit to leave the interactive session and free resources:

exit

This returns you to the login node and cancels the interactive job.

General Tips

Request Only What You Need

Always request only the resources you need. Interactive jobs hold resources even when idle, so be conservative with your requests.

Set Reasonable Time Limits

Use --time to set an appropriate time limit. If you don't specify a time, the session may be limited by default queue policies.

Use Mostly for Testing

Interactive jobs are best for testing, debugging, and short runs. For long computations, use batch scripts with sbatch.

Don't Leave Sessions Idle

Exit your session when done. Leaving interactive sessions running wastes resources and prevents others from using those nodes.