Slide 1 of 16: Best Practices for Using HPC
Rice University CRC Workshop

Best Practices for Using HPC

Scaling Up to Cluster-Native Workflows

Bridging the gap between personal laptops and large-scale, hardware-accelerated supercomputing.

Recep Erol, PhD Center for Research Computing (CRC)
Rice University Official Logo
Presenter Profile

About the Presenter

Computational Scientist for AI at Rice University Center for Research Computing

CRC Mission

We Are Your Partners in Research

An HPC cluster is not just a larger laptopβ€”it is a shared community ecosystem.

Cutting-Edge Science

You push domain boundaries in molecular dynamics, AI/LLMs, genomics, and simulations.

New Paradigms

Cluster computing introduces batch queues, parallel storage, and hardware accelerators.

Active Collaboration

CRC engineers co-design pipelines with you before runs happen, turning queue delays into speedups.

Guiding Philosophy: Everyone needs help scaling up. Our goal is empowering you to write cluster-native code that runs faster, costs less in wait time, and reproduces seamlessly.

Agenda & Roadmap

The 5 Pillars of Cluster Efficiency

Core competencies covered in this workshop

Pillar 1

The Mindset Shift

Shared resource ethics, interactive vs. batch paradigms, and login node etiquette.

Pillar 2

Data Logistics & Storage

High-speed VAST scratch vs. archives; migrating multi-TB datasets via Globus & rsync.

Pillar 3

Reproducible Environments

Containerizing workloads with Apptainer (Singularity) and automating with Makefiles.

Pillar 4

Slurm & The 3 Traps

Memory over-allocation, sequential job loops, and single-GPU lockups on multi-GPU nodes.

Pillar 5

Observability & CRC Support

Auditing jobs with seff, monitoring live GPUs with nvtop, and collaborating during office hours.

Pillar 1: Architecture

Laptop vs. Supercomputer

Moving from synchronous execution to orchestrated batch scheduling

πŸ’» Personal Laptop / Workstation

  • Dedicated Resources: 100% of CPU and RAM belongs to your single user session.
  • Synchronous Execution: You click "Run" in VS Code or Jupyter and inspect output immediately.
  • Volatile: Closing lid, system updates, or WiFi drop terminates execution.
  • Bottlenecks: Bound to 16–64 GB RAM and local battery / thermal constraints.

⚑ Shared HPC Cluster

  • Shared Community: Hundreds of researchers share multi-node interconnects.
  • Asynchronous Batch Queues: Workloads are packaged as Slurm batch scripts and submitted to a scheduler.
  • Persistent & Robust: Runs complete independently of your laptop's connection state.
  • Massive Scale: Access to TBs of distributed memory and multi-node GPU clusters.
Pillar 1: Access Etiquette

Accessing HPC: The Golden Rule

Never execute computational workloads on login nodes!

🚫 Login Nodes (Gateway Only)

[βœ• DON'T COMPUTE HERE]

Strictly intended for:

  • Submitting Slurm jobs (sbatch, squeue).
  • Editing code, text configs, and reviewing logs.
  • Transferring files, basic git commits.
⚠️ Violation: Running python train.py or compiling heavy C++ on login nodes freezes the terminal for everyone on the cluster!

βœ… Compute Nodes (The Workhorses)

[βœ“ RECOMMENDED]

Two sanctioned access methods:

Interactive Debugging:

# Request 1 GPU for 1 hour of interactive testing
salloc --partition=gpu --gres=gpu:1 --time=01:00:00 --mem=32G

Batch Production:

# Submit batch script to background queue
sbatch run_experiment.slurm
Pillar 2: Data Transfer

Moving Data at Scale

Choose the right vehicle for your data payload

πŸ“ Small to Medium (< 100 GB)

Terminal

Tool: rsync or scp

# Efficient incremental synchronization
rsync -avzP --exclude '*.tmp' ./my_dataset/ \
  re51@range.rice.edu:/scratch/re51/data/
  • Resumes interrupted transfers (-P).
  • Preserves timestamps and permissions (-a).
  • Ideal for code, configs, and preprocessed subsets.

🌐 Massive Payloads (Multi-TB)

High Throughput

Tool: Globus Transfer

  • GridFTP Engine: Maxes out campus 100GbE science DMZ.
  • Auto-Healing: Checksums every chunk and retries on dropped connections.
  • Background Execution: Does not require your laptop to remain open.
  • Direct endpoint-to-endpoint between Rice, TACC, AWS, and external universities.
Pillar 2: Storage Tiers

Storage Hygiene: Scratch vs. Archive

HPC storage is partitioned for specific I/O profiles

🏠 Home (~/home)

~10-50 GB
Quota Limited

For dotfiles, SSH keys, virtual environment definitions, and Git repositories. Never write simulation checkpoints here.

⚑ Scratch (/scratch)

VAST NVMe
High-Speed Parallel I/O

For active compute runs, checkpointing, and uncompressed datasets. Purge policy appliesβ€”clean intermediate files!

πŸ“¦ Project / Archive

Lab Shares
Long-Term Storage

For published benchmark data and final analysis results. Not for hundreds of thousands of tiny temp cache files.

⚠️ The Million Tiny Files Trap: Storing 1,000,000 loose 10KB images degrades metadata servers. Always archive or bundle datasets (e.g. tar, HDF5, WebDataset).

Pillar 3: Reproducibility

Eliminate "Works on My Machine"

Package once with Apptainer (Singularity) β€’ Run anywhere identically

πŸ“¦ Why Containers on HPC?

  • No Root Needed: Apptainer executes in unprivileged user space.
  • Direct Hardware Binding: --nv automatically passes NVIDIA driver & CUDA libraries into container.
  • Host Filesystem Mounting: Access /scratch and /home seamlessly inside.
  • Reproducibility: One .sif file encapsulates Python 3.13, PyTorch, C libraries, and CUDA.

πŸš€ Example Slurm Execution

# Run PyTorch GPU script inside container
apptainer exec --nv \
  --bind /scratch/re51:/scratch \
  /scratch/re51/containers/pytorch_2.4.sif \
  python3 /scratch/re51/code/train.py \
    --data-dir /scratch/re51/dataset

Pair with a project Makefile so that make train executes the identical recipe locally and on RANGE.

[ANTI-PATTERN #1]

Trap 1: The Memory Overallocation Trap

Requesting 128 GB "just to be safe" inflates queue wait times for days

over_allocation_bad_example.sh

#!/bin/bash
#SBATCH --job-name=mem_hog
#SBATCH --mem=128G 
# Job stays pending in queue for days for 
# resources it doesn't actually need.

python data_process.py
  • Slurm scheduler must drain nodes to carve out 128GB RAM.
  • Actual script memory peak: only 12.4 GB.
  • Wasted: 115.6 GB RAM locked away from peers.

enough_amount_allocation.sh

#!/bin/bash
#SBATCH --job-name=mem_smart
#SBATCH --mem=16G 
# Job starts quickly. Validated using `seff` 
# from a previous run.

python data_process.py
  • Slurm instantly fits this job into available node fragments.
  • Queue wait drops from 48 hours to 3 minutes.
  • Verified with: seff <jobid> (85% memory efficiency).
[ANTI-PATTERN #2]

Trap 2: The Sequential Loop Trap

Running 100 independent simulations sequentially inside a huge multi-core allocation

single_core_job_full_allocate.sh

#!/bin/bash
#SBATCH --job-name=bad_seq
#SBATCH --nodes=1
#SBATCH --ntasks=64
#SBATCH --time=48:00:00

# Wastes 63 cores while 1 task runs at a time!
for i in {1..100}; do
  python simulate.py --seed $i
done
  • CPU efficiency measured by seff: 1.5%!
  • If the node restarts at hour 47, all progress is lost.

single_core_job_slurm_jobarray.sh

#!/bin/bash
#SBATCH --job-name=smart_array
#SBATCH --array=1-100%20
#SBATCH --ntasks=1
#SBATCH --time=00:30:00

# Slurm executes tasks concurrently!
python simulate.py --seed $SLURM_ARRAY_TASK_ID
  • Slurm launches independent sub-jobs across available nodes.
  • Individual tasks retry automatically on transient failures.
[ANTI-PATTERN #3]

Trap 3: The Multi-GPU Hoarding Trap

Requesting 4 H100 GPUs for a script that only addresses cuda:0

wasting_gpu_resource.sh

#!/bin/bash
#SBATCH --job-name=gpu_hoard
#SBATCH --partition=gpu
#SBATCH --gres=gpu:4

# Script only uses single GPU cuda:0!
python single_gpu_train.py
  • GPUs 1, 2, and 3 sit completely idle ($90k+ of hardware locked).
  • Slurm fairshare score severely drops due to unused GPU billing.

correct_gpu_reseource_allocation.sh

#!/bin/bash
#SBATCH --job-name=gpu_right
#SBATCH --partition=gpu
#SBATCH --gres=gpu:1

# Perfectly matched allocation
python single_gpu_train.py
  • Immediate dispatch from the queue.
  • If multi-GPU is needed, implement PyTorch DDP / torchrun.
Pillar 5: Observability

Know Your Hardware Utilization

Audit running and finished jobs with native diagnostics

πŸ“Š Post-Mortem Audit: seff

Immediately after your job finishes, check actual resource usage:

$ seff 4819204
Job ID: 4819204
Cluster: range
State: COMPLETED (exit code 0)
Cores: 8
CPU Utilized: 03:42:10
CPU Efficiency: 88.5% of 04:12:00 core-walltime
Memory Utilized: 14.21 GB
Memory Efficiency: 88.8% of 16.00 GB

If CPU or Memory efficiency is < 40%, tune your Slurm directive on the next run!

πŸ” Live Monitoring During salloc

While testing interactively inside an allocation:

  • CPU & RAM: Run htop to inspect multi-threading and core load.
  • GPU Load & VRAM: Run nvtop or watch -n 1 nvidia-smi.
  • Disk I/O Wait: Watch if compute cores are starved waiting on slow disk reads.
πŸ’‘ Pro Tip: Profile with PyTorch Profiler or NVIDIA Nsight Systems before scaling to multi-node runs!
Pillar 3: Workflow Blueprint

Folder Structure & Slurm Hygiene

Pair submitted job scripts with their output logs

πŸ“ Recommended Project Blueprint

my_project/
β”œβ”€β”€ data/              # Symbolic link to /scratch/
β”œβ”€β”€ containers/        # Apptainer .sif images
β”œβ”€β”€ src/               # Pure Python / C++ source
β”œβ”€β”€ slurm_jobs/        # All .slurm batch scripts
β”œβ”€β”€ logs/              # Slurm stdout & stderr logs
β”‚   β”œβ”€β”€ %x_%j.out
β”‚   └── %x_%j.err
β”œβ”€β”€ Makefile           # One-command orchestration
└── README.md          # Execution recipes

🎯 Best Practices for Slurm Directives

  • Name your logs cleanly: #SBATCH --output=logs/%x_%j.out (%x=job name, %j=job ID).
  • Set realistic walltimes: Requesting 2 hours gets scheduled 10x faster than 24 hours.
  • Use email alerts for failures only: #SBATCH --mail-type=FAIL (avoid inbox spam).
  • Document software dependencies: Record git commit hash inside every batch log.
Community & Support

Let's Collaborate: We Are Here to Help!

Engage with CRC engineers during experimental design, not just when jobs fail

Open Office Hours

Every Tuesday & Thursday:

10:00 AM – 12:00 PM
1:00 PM – 3:00 PM

Drop in with code, Slurm scripts, or architecture questions.

CRC Support Tickets

Submit questions anytime:

helpdesk@rice.edu
or Service Now portal

Tag CRC for cluster, GPU, and software support.

1-on-1 Consultations

Scaling up a grant or pipeline?

Dedicated Engineering

We help optimize MPI, PyTorch DDP, and Slurm arrays.

Portal: researchcomputing.rice.edu β€’ Cluster Docs: kb.rice.edu

Questions & Discussion

Thank You!

Let's build scalable, reproducible, cluster-native science together.