0.1 The Story: The Computational Orchestra
Imagine you’re a conductor of a massive orchestra with 1,000 musicians (CPU cores), but instead of playing music, they’re processing your research data. You need to coordinate when each musician plays, what piece they perform, and ensure they don’t interfere with each other. Some pieces need the entire string section, others just a solo violin.
This is exactly what HPC job scheduling is about. The bsub command is your conductor’s baton, allowing you to orchestrate computational jobs across hundreds or thousands of processors. Today, you’ll learn to conduct your own computational symphony.
0.2 Understanding HPC Job Scheduling
0.2.1 Why We Need Job Schedulers
In the old days, if you wanted to run a program, you just typed its name and it ran immediately. But on HPC systems with hundreds of users and thousands of cores, we need a traffic controller:
Real-world analogy: It’s like an airport control tower. Planes (jobs) can’t just land whenever they want – they need permission, runway assignments, and coordination to avoid crashes.
0.2.2 The LSF (Load Sharing Facility) System
bsub is part of the LSF job scheduling system, which manages: - Queue management: Different types of jobs go to different queues - Resource allocation: Memory, CPU cores, time limits - Priority handling: Important jobs get preference - Load balancing: Distributing work across the cluster
0.3 Your First bsub Command
Let’s start with the simplest possible job submission:
What happens: 1. Your job gets assigned a unique ID 2. It goes into a queue waiting for resources 3. When resources are available, it runs 4. Output gets saved to a file
Real-world analogy: It’s like ordering food at a busy restaurant – you get a ticket number, wait in line, and eventually your order is prepared.
0.4 Understanding Job Output
When your job runs, LSF creates output files: - LSFOUT.jobid - Standard output (what your program prints) - LSFERR.jobid - Error messages (if something goes wrong)
0.5 Essential bsub Options
0.5.1 Specifying Resources
Real-world analogy: It’s like making a restaurant reservation – you tell them how many people (cores), what kind of table (memory), and how long you’ll stay (time).
0.5.2 Choosing Queues
Different queues have different characteristics: - short: Quick jobs, limited time, fast turnaround - normal: Standard jobs, moderate resources - long: Extended jobs, more time allowed - gpu: Jobs requiring GPU resources
0.5.3 Naming Your Jobs
Real-world analogy: It’s like labeling boxes when moving – you’ll thank yourself later when you need to find something specific.
0.6 Real-World HPC Scenarios
0.6.1 Scenario 1: Single Analysis Job
Breaking it down: - -J: Job name for easy identification - -n 8: Use 8 CPU cores - -M 16000: Request 16GB memory - -W 4:00: Maximum 4 hours runtime - -o/-e: Custom output/error file names - %J: Gets replaced with job ID
0.6.2 Scenario 2: Array Jobs (Processing Multiple Files)
Array job magic: - [1-100]: Creates 100 separate jobs - %I: Gets replaced with array index (1, 2, 3, …) - $LSB_JOBINDEX: Environment variable containing the array index
Real-world analogy: It’s like having 100 identical tasks and hiring 100 workers to do them simultaneously, each with a different input file.
0.6.3 Scenario 3: GPU Jobs
0.7 Job Monitoring and Management
0.7.1 Checking Job Status
Job states you’ll see: - PEND: Waiting in queue - RUN: Currently running - DONE: Completed successfully - EXIT: Failed with error
0.7.2 Detailed Job Information
0.7.3 Managing Running Jobs
Real-world analogy: It’s like having a remote control for your computational tasks – pause, stop, or check status anytime.
0.8 Advanced bsub Techniques
0.8.1 Job Dependencies
Real-world analogy: It’s like a cooking recipe where you can’t start step 3 until step 2 is finished.
0.8.2 Resource Specifications
Resource options explained: - span[hosts=1]: All cores on same physical machine - rusage[mem=4000]: 4GB memory per core - select[model==Intel_Platinum]: Specific CPU type
0.8.3 Interactive Jobs
Real-world analogy: Instead of sending a letter (batch job), you’re making a phone call (interactive session).
0.9 Professional Job Submission Scripts
0.9.1 The Standard Job Script Template
#!/bin/bash
#BSUB -J "my_analysis"
#BSUB -n 8
#BSUB -M 16000
#BSUB -W 6:00
#BSUB -o output_%J.out
#BSUB -e error_%J.err
#BSUB -q normal
# Load required modules
module load python/3.9
module load numpy/1.21
# Set up environment
export OMP_NUM_THREADS=8
cd /scratch/username/project
# Run the analysis
echo "Starting analysis at $(date)"
python analyze_data.py --input data/experiment.csv --output results/
echo "Analysis completed at $(date)"Usage:
0.9.2 Array Job Script for Multiple Files
#!/bin/bash
#BSUB -J "process_files[1-50]"
#BSUB -n 1
#BSUB -M 4000
#BSUB -W 2:00
#BSUB -o output_%I.out
#BSUB -e error_%I.err
# Load modules
module load python/3.9
# Get the input file for this array job
INPUT_FILE="data/file_${LSB_JOBINDEX}.csv"
OUTPUT_FILE="results/result_${LSB_JOBINDEX}.csv"
# Process the file
echo "Processing $INPUT_FILE"
python process_single.py --input $INPUT_FILE --output $OUTPUT_FILE
echo "Completed processing $INPUT_FILE"0.10 Monitoring System Resources
0.10.1 Cluster Status
0.10.2 Your Resource Usage
0.11 Common HPC Job Patterns
0.11.1 Pattern 1: Parameter Sweep
0.11.2 Pattern 2: Pipeline Processing
0.11.3 Pattern 3: Embarrassingly Parallel
0.12 Troubleshooting Common Issues
0.12.1 Problem 1: Job Stays in PEND State
Symptoms: Job never starts running Possible causes: - Requesting too many resources - Wrong queue selection - System maintenance
Solutions:
0.12.2 Problem 2: Job Exits Immediately
Symptoms: Job shows EXIT status quickly Solutions:
0.12.3 Problem 3: Out of Memory Errors
Symptoms: Job killed due to memory usage Solutions:
0.13 Best Practices for HPC Job Management
0.13.1 1. Resource Estimation
- Start small: Test with small datasets first
- Monitor usage: Check actual resource consumption
- Scale appropriately: Don’t over-request resources
0.13.2 2. Job Organization
0.13.3 3. Error Handling
0.14 Quick Reference: bsub Command Cheat Sheet
| Task | Command | Purpose |
|---|---|---|
| Submit simple job | bsub "command" |
Basic job submission |
| Request resources | bsub -n 4 -M 8000 "cmd" |
4 cores, 8GB memory |
| Set time limit | bsub -W 2:00 "cmd" |
2 hour maximum |
| Choose queue | bsub -q gpu "cmd" |
Submit to GPU queue |
| Array jobs | bsub -J "job[1-100]" "cmd" |
100 parallel jobs |
| Job dependency | bsub -w "done(123)" "cmd" |
Wait for job 123 |
| Interactive job | bsub -Is bash |
Interactive session |
| Check jobs | bjobs |
Show job status |
| Kill job | bkill 12345 |
Cancel job |
| Job details | bjobs -l 12345 |
Detailed information |
0.15 Practice Exercises
Submit your first job
Create an array job
Submit a resource-intensive job
Practice job control
0.16 What’s Next?
Now that you can orchestrate computational jobs like a professional, you’re ready to learn Parallel Processing Patterns. We’ll explore GNU parallel and advanced techniques for maximizing your computational throughput.
Remember: HPC job scheduling is about being a good citizen in a shared computational environment while maximizing your research productivity. Master these patterns, and you’ll be able to handle computational workloads that would be impossible on a single machine.
Before moving on, try these real-world scenarios: 1. Submit 10 jobs that each process a different parameter value 2. Create a pipeline where job B waits for job A to complete 3. Submit an interactive job and explore the compute node 4. Monitor resource usage of a running job
This practice will prepare you for managing complex computational workflows!
You’ve learned to conduct your computational orchestra with bsub. Next, we’ll explore advanced parallel processing techniques that will make your HPC workflows even more powerful!
Reuse
Citation
@online{2026,
author = {, Hasan},
title = {HPC {Job} {Scheduling} with Bsub},
date = {2026-08-23},
langid = {en}
}