Software Modules with Lmod
Overview
CUNY HPCC uses Lmod (Lua Modules) to manage software applications, compilers, libraries, and their associated environments.
Lmod allows researchers to access different software packages and versions without manually configuring environment variables or installing software themselves.
Loading a module automatically configures the necessary environment variables, such as PATH and LD_LIBRARY_PATH, allowing the selected software to be used.
Modules can also manage dependencies and help prevent conflicts between incompatible software environments.
You can view the list of available modules at the List of Available Lmod Modules page.
Getting Started
Viewing Available Software
To list software modules currently available in your environment:
module avail
To search for a particular application:
module spider python
The module spider command searches the module hierarchy, including software that may require additional modules to become available.
To display information about a specific module:
module spider <module_name>
Available applications and versions may vary depending on the cluster environment.
Loading Software
To load a software package:
module load <module_name>
To load a specific version:
module load <module_name>/<version>
Multiple modules can be loaded simultaneously:
module load <module1> <module2>
Where configured, the default version of a module may be loaded by specifying only its name.
Managing Loaded Modules
To view currently loaded modules:
module list
To unload a particular module:
module unload <module_name>
To unload all currently loaded modules:
module purge
To replace one module with another:
module swap <old_module> <new_module>
To restore the system's configured default module collection:
module reset
Note: module purge and module reset are not equivalent. Purge removes loaded modules, while reset restores the configured default environment.
Common Lmod Commands
| Command | Description |
|---|---|
module avail |
List modules available in the current environment |
module spider |
Search all modules in the module hierarchy |
module spider <name> |
Search for a specific software package |
module load <name> |
Load a software module |
module unload <name> |
Unload a software module |
module list |
Display currently loaded modules |
module show <name> |
Display a module's environment configuration |
module swap <old> <new> |
Replace one module with another |
module purge |
Unload all modules |
module reset |
Restore the configured default environment |
module help <name> |
Display help information for a module |
module save <name> |
Save the current module collection |
module restore <name> |
Restore a previously saved module collection |
Using Modules in Slurm Jobs
Software modules can be loaded directly inside Slurm batch scripts to configure the environment required by an application.
For example:
#!/bin/bash
#SBATCH --job-name=module_example
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --time=00:10:00
#SBATCH --output=module_example_%j.out
module load <module_name>
srun <application>
Replace <module_name> and <application> with the appropriate software module and executable.
Loading modules explicitly inside job scripts helps document the software environment required to reproduce a computation.
Advanced Module Management
Viewing Module Configuration
To inspect the environment changes made by a module:
module show <module_name>
This may display changes to environment variables, executable search paths, and library locations.
Understanding Module Dependencies
Some software packages require particular compilers, MPI implementations, or supporting libraries.
Lmod uses a hierarchical module system, meaning certain modules may only become available after their required dependencies are loaded.
For example, if a module is not visible through module avail, try:
module spider <module_name>
Lmod may provide instructions identifying prerequisite modules that must be loaded first.
Saving and Restoring Module Collections
Researchers who frequently use the same software environment can save their currently loaded modules:
module save research_env
To restore that environment later:
module restore research_env
Saved collections are useful for maintaining consistent software environments across sessions.
Important: Saved module collections depend on the continued availability of the referenced software versions. Researchers should document their module versions in job scripts for reproducibility.
Additional Notes
-
Software availability and default versions may change as applications are installed or updated.
-
Some modules require other modules to be loaded first.
-
Loading incompatible modules may result in dependency conflicts.
-
Researchers should verify that the required modules are available on the nodes where their jobs will execute.
-
For applications requiring specialized dependencies or isolated environments, containerized execution using Singularity/Apptainer may be appropriate.