Environment Module
Environment modules provides a reversible way to alter a user's environment to make software packages available.
Cheat Sheet
Action | Command |
---|---|
Load a module | module load gcc/6.1.1
|
Unload a module | module unload gcc
|
Show what's available | module avail
|
List what's loaded | module list
|
Creating a module
module avail
will list all modules that it can find in the search path. Any modulefile that is found will be listed as a loadable module. To get started, create a directory containing all your modulefiles. For example, /share/modulefiles
.
Add this path to module's search path with:
module use --append /share/modulefiles
Each new software package should have its own directory. Each version of the software should be its own file. For example, to create a new rstudio
module for version 1.4
:
# vi /share/modulefiles/rstudio/1.4
The modulefile
A modulefile is basically just metadata outlining what the module is for and what paths module should update for the software to work. Continuing from the rstudio example, we can have something similar to the following:
#%Module
set vers 1.4
global version
proc ModulesHelp { } {
puts stderr "\tLoads rstudio.\n"
}
module-whatis "Loads rstudio 1.4 into the environment"
module load R
module load libpq/12.4
set rootdir "/software/modules/software/rstudio-1"
prepend-path PATH "${rootdir}/usr/lib/rstudio/bin"
prepend-path LD_LIBRARY_PATH "${rootdir}/usr/lib/rstudio/lib"
# prepend-path MANPATH /usr/local/modules/mpi/gnu/man
A few things to keep in mind:
- Modulefiles start with the magic
#%Module
string - ModulesHelp is what gets run when running
module help module-name
- Dependencies are injected as '
module load
' commands. - Anti-dependencies or package conflicts are defined with
conflicts module-name
.
See also
- Official website: https://modules.sourceforge.net/
- Official documentation: https://modules.readthedocs.io/en/latest/
Alternatives
- Lmod which is based on Lua rather than TCL/C: https://github.com/TACC/Lmod
- Spack: Package manager for HPC: https://github.com/spack/spack