Key Points
Introduction to SLURM
- A job scheduler coordinates resource sharing on a cluster
- SLURM is the job scheduler on Sagehen
- The head node (2 CPUs, 8 GB RAM) is for login and job submission only
- Jobs run on compute nodes in three partitions:
amd(general compute),gpu(GPU-accelerated), andshort(quick test/debug jobs) - SLURM enforces fair access through queuing, resource limits, and priorities
Partitions and Resources
- Sagehen has three partitions:
amd(general compute),gpu(accelerators), andshort(quick / test / debug jobs) - Choose partition based on GPU need and job duration
- GPU partition offers A100 (production), L40S (inference), and RTX PRO 6000 (large-memory training)
- Per-account resource limits apply; check with
quota_check.sh -
amdandgpusupport up to 720 hours (30 days);shorthas a shorter walltime — checksinfo -p short
Requesting Resources
- Resource requests use SLURM flags:
-c(cores),--mem(memory),-t(time),--gres=gpu(GPUs) - Start conservative with estimates; monitor actual usage with
seffand adjust - Time format: HH:MM:SS or D-HH:MM:SS for longer jobs
- Use
/scratchfor fast temporary I/O during jobs; use/rhomeor/bigdatafor persistent results - Over-requesting wastes resources and makes other users wait longer
Interactive Jobs
- 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
Writing Batch Scripts
- Batch scripts are bash scripts with
#SBATCHdirectives for resource requests - First line must be
#!/bin/bash -l(the-lflag loads your environment) - Key directives:
--job-name,--cpus-per-task,--mem,--time,--partition,--output - Always load modules inside the script, not just interactively
- Use
set -eto stop on first error - Include logging (date, hostname, job ID) for debugging
- Use scratch storage for I/O-intensive intermediate files
Batch Job Submission
- Submit batch jobs with
sbatch script.sh; the returned ID is how you track everything later - Status codes: R (running), PD (pending), CG (completing), CD (done), F (failed), TO (timeout)
- The
(REASON)column for pending jobs tells you why they are not running yet - Output files use
--outputand--errordirectives;%jand%xsubstitute job ID and name - Use
tail -fto watch output in real-time while a job runs - Email:
FAILfor medium jobs,END,FAILfor long ones, nothing for tests,FAILonly for arrays - Always run
seff JOBIDafter completion to right-size future submissions - You can log out after submission; jobs run unattended
Monitoring Running Jobs
- Use
squeuefor real-time job status andwatchfor continuous monitoring - Use
sacctto view completed job history and exit codes - Use
seffto analyze resource efficiency and adjust future requests - Exit code 0 = success, 138 = timeout, 143 = cancelled
- Monitor nodes with
free -h,top, andnvidia-smi - Use
quota_check.shfor BeeGFS storage usage (notdu)
Managing and Canceling Jobs
- Use
scancel JOBIDto cancel a specific job;scancel -u $USERcancels all your jobs - Always verify the job ID before canceling
- Pending jobs: check reason with
squeue -O reason - Timeout: increase
--time; OOM: increase--mem - Script errors show as FAILED with non-zero exit code; check output files
- Ensure
#!/bin/bash -lso modules load correctly in batch scripts
GPU Job Basics
- GPUs accelerate parallel computation: deep learning, matrix math, CUDA code
- Do not use GPUs for serial, I/O-bound, or light computational tasks
- Request GPUs with
--gres=gpu:TYPE:N(e.g.,--gres=gpu:a100:1) - Always use
--partition=gpuandmodule load cudafor GPU jobs - A100 for production, L40S for prototyping and inference, RTX PRO 6000 for large-memory work
- Test GPU code interactively before submitting long batch jobs
Advanced GPU Workflows
- Monitor GPU utilization with
nvidia-smi; aim for over 80% GPU-Util - PyTorch uses
.to(device)or.cuda(); TensorFlow auto-places on GPU - Multi-GPU training requires both
--gres=gpu:2and distributed training code - CUDA OOM: reduce batch size or request a larger GPU (A100 has 80 GB)
- GPU not detected: check
--gres,module load cuda, and partition selection - Low utilization often means a CPU data-loading bottleneck or undersized batches
Job Arrays and Dependencies
- Job arrays (
--array=1-N) submit many similar jobs with one command - Each task gets a unique
$SLURM_ARRAY_TASK_IDfor parameter mapping - Use arrays for parameter sweeps, file processing, and grid searches
-
/scratchprovides fast SSD storage deleted when the job completes -
/tmpfsprovides RAM-backed storage deleted when the job ends - Always copy important results from scratch back to
/rhomeor/bigdata
Advanced Tips and Troubleshooting
- Use checkpoint/resume patterns for long jobs that might be interrupted
- Validate output files before declaring success
- Use
set -eto stop scripts on the first error - Check quota with
quota_check.shbefore large submissions - Common fixes: timeout -> more time, OOM -> more RAM, pending -> smaller resources
- Use scratch for fast I/O; always copy results back to persistent storage
- Follow the production template: logging, error handling, scratch, validation