Interactive Jobs
Exercises¶
- Get an interactive shell with srun
Use srun to start an interactive bash session on a compute node with 2 CPUs, 4G of memory, and a 30-minute time limit. Once on the node, confirm you are not on the login node by running hostname, then exit cleanly.
Hint / Solution
srun --pty --cpus-per-task=2 --mem=4G --time=00:30:00 bash
# On the compute node:
hostname # Should show a compute node name, not the login node
nproc # Should show at least 2
exit # Release the allocation
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- Allocate resources with salloc, then run commands
Use salloc to reserve 4 CPUs and 8G of memory for 1 hour. Then use srun within that allocation to run hostname and free -m on the allocated node. Release the allocation when done.
Hint / Solution
salloc --cpus-per-task=4 --mem=8G --time=01:00:00
# You're still on the login node but have reserved resources
srun hostname
srun free -m
# Release
exit
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- Request X11 forwarding for a graphical application
First, SSH to the cluster with X11 forwarding enabled. Then use srun with --x11 to start an interactive session. Verify X11 is working by running xeyes or xclock (if available), or by checking that the $DISPLAY environment variable is set.
Hint / Solution
- Run a single command on a compute node without an interactive shell
Use srun (without --pty or bash) to run a single command on a compute node. Check which Linux kernel version is running on the compute nodes by executing uname -a.
Hint / Solution
This runs the command on a compute node and prints the result directly to your terminal without starting an interactive session. Expected output: Validated 2026-04-15 onslurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).