Environment Modules on VHPC (Lmod)
On the VHPC cluster, we use Lmod (a modern, Lua-based implementation of environment modules) rather than the older TCL-based Environment Modules
system. Lmod provides backward compatibility with most module
commands, but also includes enhancements such as hierarchical module naming, module collections, and more descriptive error messages.
Basic Commands
The following commands are used to manage your environment on VHPC. They are mostly compatible with TCL module syntax, but Lmod introduces some improvements.
Listing Modules
module avail
Shows all available modules. In Lmod, output is organized by category and path.
module spider <name>
Searches for modules by name, including hidden ones, and shows how to load them.
Loading Modules
module load GCC/12.2.0
Loads the specified module.
Multiple modules can be loaded at once:
module load GCC/12.2.0 OpenMPI/4.1.4-GCC-12.2.0
Unloading Modules
module unload OpenMPI
Removes the specified module from your environment.
Swapping Modules
module swap GCC/11.3.0 GCC/12.2.0
Unloads the first module and loads the second.
Inspecting Modules
module show OpenMPI
Displays the environment changes a module makes.
module help OpenMPI
Displays the help message for the module.
Getting Help
To see help about the module command itself (including subcommands):
module help
You can also use --help
or -h
to get the same thing:
module --help
The ml
Shortcut
Lmod provides the ml
command as a shorter alternative to module
.
Examples:
ml GCC/12.2.0 OpenMPI/4.1.4-GCC-12.2.0 # load multiple modules
ml -OpenMPI # unload a module
ml # list currently loaded modules
ml
is especially convenient for quick interactive use.
Managing Your Environment
Saving a Collection
In Lmod, you can save your currently loaded set of modules as a named collection:
module save my_workflow
Later, restore the same environment with:
module restore my_workflow
List your collections:
module savelist
Delete a collection:
module reset my_workflow
Default Collection
You can define a default module collection to be loaded on login:
module save default
To clear all loaded modules and return to the system defaults:
module purge
Differences from TCL Modules
- Compatibility: Most TCL
module
commands (load
,unload
,list
,avail
,swap
) work as expected. - Additional Tools: Lmod introduces
module spider
,module save
, andmodule restore
for advanced environment management. - Collections vs initfiles: TCL used
module initadd
and related commands to persist modules; in Lmod you should use collections instead. - Hierarchical modules: Some software may only appear in
module avail
after loading a compiler or MPI library first.
Useful Commands Summary
module avail
— List available modules.module spider <name>
— Search for modules.module load <name>
— Load a module.module unload <name>
— Unload a module.module swap <old> <new>
— Swap modules.module list
— Show currently loaded modules.module show <name>
— Inspect a module’s environment.module save <name>
— Save current module collection.module restore <name>
— Restore a saved collection.module purge
— Remove all loaded modules.