Skip to content

5. Environment Modules

The ABCI system offers various development environments, MPIs, libraries, utilities, etc. listed in 1.3. Software Configuration. And, users can use these software in combination as modules.

Environment Modules allows users to configure their environment settings, flexibly and dynamically, required to use these modules.

Usage

Users can configure their environment using the module command:

$ module [options] <sub-command> [sub-command options]

The following is a list of sub-commands.

Sub-command Description
list List loaded modules
avail List all available modules
show module Display the configuration of "module"
load module Load a module named "module" into the environment
unload module Unload a module named "module" from the environment
switch moduleA moduleB Switch loaded "moduleA" with "moduleB"
purge Unload all loaded modules (Initialize)
help module Print the usage of "module"

Use cases

Loading modules

[username@g0001 ~]$ module load cuda/10.0/10.0.130.1 cudnn/7.6/7.6.2

List loaded modules

[username@g0001 ~]$ module list
Currently Loaded Modulefiles:
  1) cuda/10.0/10.0.130.1   2) cudnn/7.6/7.6.2

Display the configuration of modules

[username@g0001 ~]$ module show cuda/10.0/10.0.130.1
-------------------------------------------------------------------
/apps/modules/modulefiles/gpgpu/cuda/10.0/10.0.130.1:

module-whatis    cuda 10.0.130.1
conflict     cuda
prepend-path     CUDA_HOME /apps/cuda/10.0.130.1
prepend-path     CUDA_PATH /apps/cuda/10.0.130.1
prepend-path     PATH /apps/cuda/10.0.130.1/bin
prepend-path     LD_LIBRARY_PATH /apps/cuda/10.0.130.1/lib64
prepend-path     CPATH /apps/cuda/10.0.130.1/include
prepend-path     LIBRARY_PATH /apps/cuda/10.0.130.1/lib64
prepend-path     MANPATH /apps/cuda/10.0.130.1/doc/man
-------------------------------------------------------------------

Unload all loaded modules (Initialize)

[username@g0001 ~]$ module purge
[username@g0001 ~]$ module list
No Modulefiles Currently Loaded.

Load dependent modules

[username@g0001 ~]$ module load cudnn/7.6/7.6.2
WARNING: cudnn/7.6/7.6.2 cannot be loaded due to missing prereq.
HINT: at least one of the following modules must be loaded first: cuda/9.0 cuda/9.2 cuda/10.0

Due to dependencies, you will not be able to load cudnn/7.6/7.6.2 without loading either cuda/9.0, cuda/9.2, or cuda/10.0 module first.

[username@g0001 ~]$ module load cuda/10.0/10.0.130.1
[username@g0001 ~]$ module load cudnn/7.6/7.6.2

Load exclusive modules

Modules that are in an exclusive relationship, such as modules of different versions of the same library, cannot be used at the same time.

[username@g0001 ~]$ module load cuda/10.0/10.0.130.1
[username@g0001 ~]$ module load cuda/9.2/9.2.148.1
cuda/9.2/9.2.148.1(5):ERROR:150: Module 'cuda/9.2/9.2.148.1' conflicts with the currently loaded module(s) 'cuda/10.0/10.0.130.1'

Switch modules

[username@g0001 ~]$ module switch python/2.7/2.7.15 python/3.6/3.6.5

Switching may not be successful if there are dependencies.

[username@g0001 ~]$ module load cuda/10.0/10.0.130.1
[username@g0001 ~]$ module load cudnn/7.6/7.6.2
[username@g0001 ~]$ module switch cuda/10.0/10.0.130.1 cuda/9.2/9.2.148.1
[username@g0001 ~]$ env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/apps/cudnn/7.6.2/cuda10.0/lib64:/apps/cuda/9.2.148.1/lib64

CUDA9.2 and cuDNN for CUDA10.0 are loaded.

As shown below, it is necessary to unload modules that depend on the target module in advance and reload them after switching.

[username@g0001 ~]$ module load cuda/10.0/10.0.130.1
[username@g0001 ~]$ module load cudnn/7.6/7.6.2
[username@g0001 ~]$ module unload cudnn/7.6/7.6.2
[username@g0001 ~]$ module switch cuda/10.0/10.0.130.1 cuda/9.2/9.2.148.1
[username@g0001 ~]$ module load cudnn/7.6/7.6.2
[username@g0001 ~]$ env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/apps/cudnn/7.6.2/cuda9.2/lib64:/apps/cuda/9.2.148.1/lib64

Usage in a job script

When using the module command in a job script for a batch job, it is necessary to add initial settings as follows.

sh, bash:

source /etc/profile.d/modules.sh
module load cuda/10.0/10.0.130.1

csh, tcsh:

source /etc/profile.d/modules.csh
module load cuda/10.0/10.0.130.1