HPC Software Modules (Python, PyTorch, Julia)¶
Overview¶
The Department of Statistics HPC provides centrally managed software via a shared
/apps filesystem using Environment Modules.
This allows you to:
Load specific software versions on demand
Switch between versions easily
Use consistent, supported environments across all compute nodes
Available Software¶
You can see available modules with:
module avail
Example output:
/apps/modulefiles/Core:
conda/miniforge3
julia/1.11.3
python/3.10.20
python/3.11.15
python/3.12.13
pytorch/cu124-py310
pytorch/cu124-py311
aiml/py311
Basic Usage¶
Before using modules, initialise the module system:
source /etc/profile.d/modules.sh
Then:
module purge
module use /apps/modulefiles/Core
module load <module-name>
Examples¶
Python¶
module purge
module use /apps/modulefiles/Core
module load python/3.11.15
python3 --version
PyTorch (GPU)¶
module purge
module use /apps/modulefiles/Core
module load pytorch/cu124-py311
python -c "import torch; print(torch.cuda.is_available())"
Julia¶
module purge
module use /apps/modulefiles/Core
module load julia/1.11.3
julia --version
AI/ML Environment¶
module purge
module use /apps/modulefiles/Core
module load aiml/py311
python -c "import numpy, pandas, sklearn, torch; print('ok')"
Using Modules in Slurm Jobs¶
In Slurm jobs, the module system is not always automatically available.
You should initialise it explicitly.
Example:
#!/bin/bash
#SBATCH --job-name=test_python
#SBATCH --partition=standard-gpu
#SBATCH --clusters=srf_gpu_01
#SBATCH --gres=gpu:1
#SBATCH --cpus-per-task=2
#SBATCH --mem=4G
#SBATCH --time=00:05:00
#SBATCH --output=test_python_%j.out
set -euo pipefail
source /etc/profile.d/modules.sh
module purge
module use /apps/modulefiles/Core
module load python/3.10.20
echo "Python executable:"
which python3
echo "Python version:"
python3 --version
Common Issue: module: command not found¶
If you see:
module: command not found
initialise the module system first:
source /etc/profile.d/modules.sh
Conda / Miniforge¶
A shared Conda installation is available:
module load conda/miniforge3
Please see Storage for details on persistent vs temporary storage.
Persistent Conda Environment with Fast Package Cache¶
This is the recommended setup for most users.
Store the Conda environment persistently in /bitbucket/$USER/ while keeping the package cache on fast SSD-backed scratch storage.
Example:
module load conda/miniforge3
# Configure package cache on fast scratch
mkdir -p "$SCRATCH_FAST/conda-pkgs"
conda config --add pkgs_dirs "$SCRATCH_FAST/conda-pkgs"
# Create persistent environment
mamba create -y -p /bitbucket/$USER/conda-envs/myenv python=3.11
# Activate environment
source /apps/conda/miniforge3/bin/activate \
/bitbucket/$USER/conda-envs/myenv
Benefits:
Persistent environment
Faster package operations
Reduced load on home directories
Temporary Per-Job Environment¶
For temporary or rebuildable environments:
module load conda/miniforge3
mkdir -p "$SCRATCH_FAST/conda-envs"
mamba create -y \
-p "$SCRATCH_FAST/conda-envs/myenv" \
python=3.11
source /apps/conda/miniforge3/bin/activate \
"$SCRATCH_FAST/conda-envs/myenv"
Warning
/scratch storage is temporary and automatically wiped after 30 days.
Pixi / Rattler Cache¶
Pixi and Rattler perform many filesystem operations and may perform better with caches on fast scratch storage.
Example:
export RATTLER_CACHE_DIR="$SCRATCH_FAST/rattler-cache"
General Performance Guidance¶
For best performance:
Keep package caches on
$SCRATCH_FASTAvoid large Conda or Pixi caches in
$HOMEKeep rebuildable environments on scratch storage where possible
Use persistent storage such as
/bitbucket/$USER/for environments you wish to keep long-term
Note
Home directories are currently HDD-backed storage, while /scratch/fast uses SSD-backed storage.
Performance is generally best when package caches are stored on $SCRATCH_FAST.
Best Practices¶
Always start with:
module purgeAlways load modules explicitly in scripts
Use shared modules for stable, supported environments
Use personal Conda environments for experimentation
Summary¶
The module system provides:
Consistent software across the cluster
Easy version switching
Preconfigured GPU and AI environments
If unsure, start with:
module avail