Skip to content

Environment Modules


Overview

Environment modules provide a flexible way to manage your software environment on shared systems such as HPC clusters.

They allow you to dynamically modify your shell environment to: - Load specific software packages - Switch between versions - Manage dependencies cleanly


Why use environment modules?

On shared systems, multiple users and applications require different software versions.

Environment modules help: - Avoid conflicts between software - Ensure reproducibility - Simplify environment setup - Provide access to centrally installed tools


Basic usage

The module command is used to interact with environment modules.

The ​module command is used to manage environment modules, and has many options, the most useful of which are detailed below.​ For all the available commands see the Lmod user guide


Discovering available modules

To see all available modules:

module avail
...
---------------- /cvmfs/fsl.fmrib.ox.ac.uk/el9/modules ----------------
   fsl/4.1.9          fsl_sub/2.8.3        (L)
   fsl/5.0.9          fsl_sub_config/1.0.0
   fsl/5.0.11         fsl_sub_config/1.0.1
   fsl/6.0.7.3 (D)    fsl_sub_config/1.0.2 (L,D)

---------------- /cvmfs/matlab.fmrib.ox.ac.uk/modules -----------------
   MATLAB/R2012a        MATLAB_MCR/R2012a    MATLAB_MCR/R2019b
   MATLAB/R2014b        MATLAB_MCR/R2012b    MATLAB_MCR/R2023a
   MATLAB/R2023b (D)    MATLAB_MCR/R2014b    MATLAB_MCR/R2023b (D)
...

This lists software grouped by category.

For a more concise summary:

module overview

Loading modules

To load a module:

module load <module_name>

Example:

module load freesurfer

Module versions

Modules are typically named like:

<software>/<version>

Example:

module load MATLAB/2023b

If no version is specified, the default version is loaded.


Checking loaded modules

To list currently loaded modules:

module list

Unloading modules

To unload a specific module:

module unload <module_name>

Example:

module unload freesurfer/7.4.0

To remove all modules:

module purge

Switching modules

To switch versions:

module switch <old> <new>

Example:

module switch freesurfer/6.0.0 freesurfer/7.4.0

Tips

  • Always check loaded modules before running jobs
  • Use specific versions for reproducibility
  • Add frequently used modules to your shell config if appropriate