Submitting SLURM Jobs#
KLC Reserve jobs run on the kellogg SLURM partition. You submit a shell script that declares the resources your job needs; SLURM schedules the job and runs it on dedicated nodes whether you remain logged in or not. This page covers how to write, submit, monitor, and tune batch and interactive SLURM jobs.
For the decision between interactive login work and scheduled jobs, see When to Use KLC Reserve. For GPU-specific requests, see GPU Jobs. For the dedicated high-memory CPU node, see High-Memory Jobs. For comprehensive SLURM reference, see the Quest SLURM documentation .
Prerequisites#
A KLC account and an active session on any KLC node
A Kellogg SLURM account with access to the
kelloggpartition (verify withgroups)Job scripts and output stored under
/kellogg/proj/<your-netid>/, not your 80 GB home directory
A Minimal Batch Script#
Save this as myjob.sh:
#!/bin/bash
#SBATCH --account=kellogg ## Kellogg SLURM account
#SBATCH --partition=kellogg ## Kellogg Reserve partition
#SBATCH --job-name=my-analysis
#SBATCH --nodes=1
#SBATCH --ntasks=8 ## CPU cores
#SBATCH --mem=64G ## RAM; request ~110% of expected peak use
#SBATCH --time=04:00:00 ## Wall time limit HH:MM:SS
#SBATCH --output=logs/slurm-%j.out ## stdout/stderr; %j = job ID
## Load software
module purge
module use --append /kellogg/software/Modules/modulefiles
module load mamba/24.3.0
source activate /kellogg/proj/<your-netid>/envs/my-env
## Run your code
cd /kellogg/proj/<your-netid>/project
python analysis.py
Submit it:
sbatch myjob.sh
SLURM returns a job ID immediately and your job enters the queue:
Submitted batch job 1234567
Partition Limits (kellogg)#
Policy |
Value |
|---|---|
|
|
Maximum wall time |
48 hours per job |
Concurrent job limit |
None |
Default memory |
3 GB per core (if |
Request --mem explicitly when your job needs more than the per-core default.
Key #SBATCH Options#
Option |
What it controls |
|---|---|
|
SLURM account to charge; required |
|
Node pool; use |
|
Physical machines; keep at 1 unless using MPI |
|
CPU cores; increase only if your code parallelizes |
|
RAM per node |
|
Maximum wall time; job is killed if it exceeds this |
|
File for stdout and stderr ( |
|
Request one GPU (for GPU jobs; see GPU Jobs) |
Warning
--ntasks without --nodes=1 can spread cores across multiple machines. Unless your code uses MPI, always pair --ntasks with --nodes=1.
Note
Run groups after logging into any KLC node to see the SLURM account names you belong to. Contact rs@kellogg.northwestern.edu if your jobs fail to submit.
Interactive Sessions#
For interactive work on a reserved node — useful for debugging or testing resource-intensive steps — use salloc:
salloc --account=kellogg \
--partition=kellogg \
--nodes=1 --ntasks=4 --mem=32G \
--time=01:00:00
Once the allocation is granted, SLURM sets $SLURM_NODELIST and similar environment variables in your shell. To open an interactive shell on the allocated compute node, run:
srun --pty bash
This launches a bash session directly on the assigned node. When you are done, type exit to leave the srun session, then exit again to release the salloc allocation.
You can also use srun to run a single command on the allocated node without opening a full shell:
srun python my_script.py
To request a GPU interactively, add --gres=gpu:1 to your salloc command:
salloc --account=kellogg \
--partition=kellogg \
--nodes=1 --ntasks=4 --mem=32G \
--gres=gpu:1 --time=01:00:00
Then connect to the node and verify the GPU is visible:
srun --pty bash
nvidia-smi
For GPU setup and batch examples, see GPU Jobs.
Using srun Directly (One-Step Alternative)#
You can skip salloc entirely and let srun handle both allocation and execution in a single command:
srun --account=kellogg \
--partition=kellogg \
--nodes=1 --ntasks=4 --mem=32G \
--time=01:00:00 \
--pty bash
For a GPU session:
srun --account=kellogg \
--partition=kellogg \
--nodes=1 --ntasks=4 --mem=32G \
--gres=gpu:1 --time=01:00:00 \
--pty bash
This is the simpler option for a quick one-off session. The tradeoff is that each srun call competes for resources independently — if you need to run several sequential steps and want them all to share the same allocation without requeuing, use salloc + srun instead.
Job Arrays#
Run the same script on many inputs with a job array. Each task receives a unique index in $SLURM_ARRAY_TASK_ID:
#!/bin/bash
#SBATCH --account=kellogg
#SBATCH --partition=kellogg
#SBATCH --job-name=batch-analysis
#SBATCH --array=1-50 ## Tasks indexed 1 through 50
#SBATCH --nodes=1
#SBATCH --ntasks=4
#SBATCH --mem=16G
#SBATCH --time=01:00:00
#SBATCH --output=logs/job-%A_%a.out ## %A = array job ID, %a = task index
module purge
module use --append /kellogg/software/Modules/modulefiles
module load mamba/24.3.0
source activate /kellogg/proj/<your-netid>/envs/my-env
INPUT_FILE=/kellogg/proj/<your-netid>/data/input_${SLURM_ARRAY_TASK_ID}.csv
python process.py --input $INPUT_FILE \
--output /kellogg/proj/<your-netid>/results/output_${SLURM_ARRAY_TASK_ID}.csv
All tasks run in parallel subject to partition capacity.
Monitoring and Cancelling Jobs#
# Queued and running jobs
squeue -u $USER
# Expected start time for a pending job
squeue -j <job-id> --start
# Detailed status
checkjob <job-id>
# Resource efficiency after completion
seff <job-id>
# Cancel a job
scancel <job-id>
seff reports CPU efficiency and actual vs. requested memory — use it after each run to tighten your resource requests and reduce queue wait time.
Common Pitfalls#
Symptom |
Likely cause |
What to do |
|---|---|---|
|
Wrong |
Run |
Job stays |
Cluster busy or request too large |
Check |
Job fails immediately |
Missing |
Test the exact commands interactively first |
Job ends with |
|
Increase |
Job ends with |
|
Increase |
Empty or missing output file |
Wrong |
Create the log directory before submitting; use an absolute path under |
|
Missing |
Always add |
GPU not visible in Python |
CUDA environment not loaded |
Load the correct CUDA module; see GPU Jobs |
Practical Workflow#
Develop interactively on a login node with a small sample. Fix bugs and tune parameters.
Capture commands in a SLURM script — same
module loadsteps and working directory.Submit one test job on representative data; confirm output and runtime.
Scale with a job array if you have many inputs.
Tune resources with
seffbefore the next large run.
Further Reading#
Quest SLURM documentation — comprehensive
#SBATCHreferenceWhen to Use KLC Reserve — when to use SLURM vs. direct login
Launching Jobs on KLC — capture interactive logs with
tee(equivalent to#SBATCH --outputon KLC main)Using tmux — keeping interactive sessions alive on KLC main
GPU Jobs — GPU requests on the
kelloggpartitionHigh-Memory Jobs — dedicated high-memory CPU node (
qhimem0501)KLC Reserve overview — available hardware