You are here

Environment Modules

Last update: Jan 27, 2023

Introduction

*Environment Modules ("module" command) is an OPTIONAL tool in RCCS*
You can set PATH or LD_LIBRARY_PATH environment variables in your setting files and
load config files provided by applications as it always has been.

Pros of environment modules in RCCS

  • able to simplify complicated settings of certain applications.
  • no need to care about the location of setting files of applications.
  • easy to switch environment (e.g. CUDA 8.0/9.1 or Intel MPI/Open MPI).

Cons of environment modules in RCCS

  • If your login shell OR your job script is csh, extra lines are required in job script.
    • If both of login shell and job scripts are written in sh/bash, extra lines are not required.
    • if your job script is csh script, "source /etc/profile.d/modules.csh" is required in job submission script before using module command
    • if your login shell is csh but the job script is bash script, you need to add "source /etc/profile.d/modules.sh" in the script.
  • if you already have very complicated settings, it is terribly difficult to migrate.
  • no significant advantage for certain applications (e.g. most versions of gromacs).

Basic Usage

Loading/unloading modules can be done by "module" command. This command is available both in login server and computation nodes.
If you are using csh script for job submission, you may need to pay special attention in your script.

  • "load" module (some of modules are automatically loaded when you login)

% module load (module name)

  • "unload" (or remove) modules. In some cases, module dependencies could broken by this command due to their complexity. If you met the situation, please "purge" first and then "load" modules.

% module unload (module name)

  • "purge"; unload all the modules

% module purge

  • show available modules (if you omit path, all the available modules will be shown)

% module avail (path; optional)

  • show "list" of loaded modules

% module list

  • show brief explanations of modules (length of about single line; if you omit module name, messages for all the modules will be shown)

% module whatis (module name; optional)

  • save current module status. If the name is omitted, "default" is used. The "default" save will be restored automatically upon login.
    • Your private module settings (including module path) can be saved and can be restored. Saved collection can be restored by "module restore (save name)" command.

% module save (save name; optional)

  • remove a saved collection. "default" will be removed if the name omitted.

% module saverm (save name; optional)

default module

The default version is specified for most modules. If you load a module without specifying module versions,
the default version will be loaded.

% module purge
% module avail openmpi
------------------------- /home/users/qf7/modules/util -------------------------
openmpi/3.1.6/aocc3          openmpi/4.1.4-hpcx/gcc11          
openmpi/3.1.6/aocc4          openmpi/4.1.4-hpcx/nv22           
openmpi/3.1.6/gcc8           openmpi/4.1.5-hpcx/               
openmpi/3.1.6/gcc9           openmpi/4.1.5-hpcx/aocc3          
openmpi/3.1.6/gcc10          openmpi/4.1.5-hpcx/aocc4          
openmpi/3.1.6/gcc11          openmpi/4.1.5-hpcx/gcc8           
openmpi/3.1.6/intel2022.2.1  openmpi/4.1.5-hpcx/gcc9           
openmpi/3.1.6/nv22           openmpi/4.1.5-hpcx/gcc10          
openmpi/4.1.4-hpcx/aocc3     openmpi/4.1.5-hpcx/gcc11          
openmpi/4.1.4-hpcx/aocc4     openmpi/4.1.5-hpcx/intel2022.0.2  
openmpi/4.1.4-hpcx/gcc8      openmpi/4.1.5-hpcx/intel2022.2.1  
openmpi/4.1.4-hpcx/gcc9      openmpi/4.1.5-hpcx/nv22           
openmpi/4.1.4-hpcx/gcc10     

Key:
modulepath  directory/  default-version
% module load openmpi
Loading openmpi/4.1.5-hpcx/gcc8
  Loading requirement: pbs/22.05.11
% module list
Currently Loaded Modulefiles:
 1) pbs/22.05.11   2) openmpi/4.1.5-hpcx/gcc8(default:openmpi)  

Key:
(symbolic-version)  default-version  auto-loaded

You can omit package version upon unloading, too.

% module list
Currently Loaded Modulefiles:
 1) pbs/22.05.11   2) openmpi/4.1.5-hpcx/gcc8(default:openmpi)  

Key:
(symbolic-version)  default-version  auto-loaded  
% module unload openmpi
Unloading openmpi/4.1.5-hpcx/gcc8
  Unloading useless requirement: pbs/22.05.11
% module list
No Modulefiles Currently Loaded.

 

Sample Usage in Job Submission Script

Conventional Way (sh)

#!/bin/sh
#PBS select=ncpus=1:mpiprocs=1:ompthreads=1:ngpus=1
#PBS -l walltime=72:00:00

if [ ! -z $PBS_O_WORKDIR ]; then
  cd $PBS_O_WORKDIR
fi

export PATH=/local/apl/lx/cuda-9.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/local/apl/lx/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
. /local/apl/lx/amber18-bf1/amber.sh

pmemd.cuda -O -i mdin ......

Using Environment Modules

#!/bin/sh
#PBS select=ncpus=1:mpiprocs=1:ompthreads=1:ngpus=1
#PBS -l walltime=72:00:00

if [ ! -z $PBS_O_WORKDIR ]; then
  cd $PBS_O_WORKDIR
fi

module load amber/18/bugfix1

pmemd.cuda -O -i mdin ......

If your login shell is csh, you need to add "source /etc/profile.d/modules.sh"(source can be replaced with ".") before module load command.

Using Environment Modules in csh job script

For csh/tcsh, module command is defined as an alias in /etc/profile.d/modules.csh.
You don't need a special setting in interactive shell.
However, in the job script, you need to source /etc/profile.d/modules.csh explicitly.

#!/bin/csh -f
#PBS select=ncpus=1:mpiprocs=1:ompthreads=1:ngpus=1
#PBS -l walltime=72:00:00

if ( $?PBS_O_WORKDIR ) then
  cd $PBS_O_WORKDIR
endif

source /etc/profile.d/modules.csh # required!
module load amber/18/bugfix1

pmemd.cuda -O -i mdin .......

Reference