Interactive Jobs
Last updated on 2026-08-24 | Edit this page
Overview
Questions
- How do I get an interactive shell on a compute node?
- How do I request resources for an interactive session?
- When should I use interactive vs batch jobs?
Objectives
- Master
srun --pty bashfor interactive sessions - Request CPU, memory, and GPU resources for interactive jobs
- Use interactive sessions for development and debugging
- Know when to switch to batch jobs
The srun Command
srun starts interactive jobs. The most common form for a
short interactive debugging session:
-
-c 4: 4 CPU cores -
--mem=16G: 16 GB RAM -
-t 00:30:00: 30 minutes -
-p short:shortpartition (good for short interactive work; for sessions longer than theshortwalltime limit, use-p amd) -
--pty bash -l: interactive login shell
After SLURM allocates resources, your prompt changes to show the compute node:
[user@compute-node ~]$
Type exit or Ctrl+D to end the session and free
resources.
Common Interactive Patterns
Working in Interactive Sessions
Load modules and run code just like on your laptop:
Edit and rerun for iterative development:
When to Use Interactive vs Batch
Interactive: developing code, debugging, exploring data, quick tests
Batch: stable code, jobs over 2 hours, many parallel jobs, unattended runs
Challenge 1: Your First Interactive Session
Start a session:
srun -c 2 --mem=8G -t 00:10:00 -p short --pty bash -l-
Verify you are on a compute node:
-
Load Python and run a quick test:
Exit:
exitConfirm you are back on the head node:
hostname
Inside the session, hostname shows a compute node (e.g.,
a005), free -h shows 500 GB total RAM, and
nproc shows 128 cores. After exit,
hostname returns sagehen. The Python test
confirms modules work on compute nodes.
- Use
srun --pty bash -lfor interactive sessions on compute nodes - Request resources:
-c(cores),--mem(RAM),-t(time),-p(partition) - Interactive jobs are best for development, testing, and debugging
- Use the
shortpartition for short interactive sessions and quick debugging; useamdfor longer interactive work - Use tmux inside sessions for connection resilience
- Switch to batch jobs when code is stable and needs long or unattended runs