Difference between revisions of "Environment Modules"

From bwHPC Wiki
Jump to: navigation, search
(Viewing the Changes Introduced by a Module)
Line 177: Line 177:
 
The solution is [[#Unloading Modules|unloading]] or switching ''Modules''.
 
The solution is [[#Unloading Modules|unloading]] or switching ''Modules''.
   
  +
  +
== Viewing the Changes Introduced by a Module ==
  +
  +
Loading a module will change the environment of the current shell. The PATH variable will be adjusted to include the program in every module, other variables may change the behavior of the shell or programs being run from it in a more drastic way.
  +
  +
Modules installed on the bwHPC systems will also set a number of convenience variables, pointing to places of the installation that might be of interest.
  +
  +
All the changes made by the module can be reviewed using
  +
  +
module show category/programname/0.0.0
   
 
=== Automatic Loading ===
 
=== Automatic Loading ===
Line 198: Line 208:
 
From now on, whenever you log in, the default version of the Intel compiler is automatically
 
From now on, whenever you log in, the default version of the Intel compiler is automatically
 
loaded in your environment.
 
loaded in your environment.
 
   
 
=== Modules depending on Modules ===
 
=== Modules depending on Modules ===

Revision as of 15:01, 2 May 2014



The usage of compilers, libraries and software packages requires by default users to set up manually their session environment. The bwHPC clusters (such as bwUniCluster) provide users the possibility to load and unload complete environments for compilers, libraries and software packages by single commands. Because of the convenient modularity this package is called Environment Modules, or short Modules.


Modules
License GPL
Links http://modules.sourceforge.net/


1 Description

The Environment Modules package enables dynamic modification of your environment by the use of so-called modulefiles. A modulefile contains information to configure the shell for a program/software . Typically, a modulefile contains instructions that alter or set shell environment variables, such as PATH and MANPATH, to enable access to various installed software.

One of the key features of using the Environment Modules software is to allow multiple versions of the same software to be used in your environment in a controlled manner. For example, two different versions of the Intel C compiler can be installed on the system at the same time - the version used is based upon which Intel C compiler modulefile is loaded.

The software stack of bwHPC clusters provides a number of modulefiles. You can also create your own modulefiles. Modulefiles may be shared by many users on a system, and users may have their own collection of modulefiles to supplement or replace the shared modulefiles.

A modulefile does not provide configuration of your environment until it is explicitly loaded, i.e., the specific modulefile for a software product or application must be loaded in your environment before the configuration information in the modulefile is effective. For instance loading the default Intel C and Fortran compiler you must execute:

$ module load compiler/intel


2 Usage

2.1 Documentation

For help on how to use Modules software, i.e., the command module, execute:

$ module help

or

$ man module

For help on particular version of Module, e.g. Intel compiler version X.Y, execute:

$ module help compiler/intel/X.Y


2.2 Display all available Modules

Available Module are modulefiles that can be loaded by the user. A Module must be loaded before it provides changes to your environment, as described in the introduction to this section. You can display all available Modules on the system by executing:

$ module avail

The short form the command is:

$ module av

Available Modules can be also displayed in different modes, such as

  • each Module per one line
$ module -t avail
  • long
$ module -l avail


2.3 Module categories, versions and defaults

The bwHPC clusters (such as bwUniCluster) traditionally provide a large variety of software and software versions. Therefore Module are divided in category folders containing subfolders of modulefiles again containing modulefile versions, and must be addressed as follows:

category/softwarename/version

For instance the Intel compiler X.Y belongs to the category of compilers, therefore the modulefile X.Y is placed under the category compiler and intel.

In case of multiple software versions, one version will be always defined as the default version. The Module of the default can be addressed by simply omitting the version number:

category/softwarename


2.4 Finding software Modules

Currently all bwHPC software packages are assigned to the following Module categories:

You can selectively list software in one of those categories using, e.g. for the category "compiler"

$ module avail compiler/

Searches are looking for a substring starting at the begin of the name, so this would list all software in categories starting with a "c"

$ module avail c

while this would find nothing

$ module avail hem


2.5 Loading Modules

You can load a Module software in to your environment to enable easier access to software that you want to use by executing:

$ module load category/softwarename/version

or

$ module add category/softwarename/version

Loading a Module in this manner affects ONLY your environment for the current session.


2.5.1 Loading conflicts

By default you can not load different versions of same software Module in same session. Loading for example Intel compiler version X while Intel compiler version Y is loaded results in error message as follows:

ERROR:150: Module 'compiler/intel/X' conflicts with the currently loaded module(s) 'compiler/intel/Y'

The solution is unloading or switching Modules.


2.6 Viewing the Changes Introduced by a Module

Loading a module will change the environment of the current shell. The PATH variable will be adjusted to include the program in every module, other variables may change the behavior of the shell or programs being run from it in a more drastic way.

Modules installed on the bwHPC systems will also set a number of convenience variables, pointing to places of the installation that might be of interest.

All the changes made by the module can be reviewed using

module show category/programname/0.0.0

2.6.1 Automatic Loading

If you frequently use one or more Modules that are not loaded when you log in to the system, you can set up your environment to automatically load those Modules for you. A method for doing this is to modify your shell startup script to include instructions to load the modulefile automatically.

For example, if you want to automatically load the Module of Intel's default compiler when you log in, edit your shell startup script to include the following instructions. This example assumes that you use bash as your login shell. Edit the $HOME/.bashrc file as follows:

## if the ’module’ command is defined, $MODULESHOME will be set
if [ -n "$MODULESHOME" ]; then
   module load compiler/intel
fi

From now on, whenever you log in, the default version of the Intel compiler is automatically loaded in your environment.

2.6.2 Modules depending on Modules

Some program Modules depend on libraries to be loaded to the user environment. Therefore the corresponding Modules of the software must be loaded together with the Modules of the libraries.

By default such software Modules try to load required Modules and corresponding versions automatically. However, automatic loading might fail if a different version of that required Module is already loaded (cf. Loading conflicts).


2.7 Unloading Modules

To unload or to remove a software Module execute:

$ module unload category/softwarename/version

or

$ module remove category/softwarename/version

Unloading a Module that has been loaded by default makes it inactive for the current session only - it will be reloaded the next time you log in.

In order to remove all previously loaded software modules from your environment issue the following command:

$ module purge


2.8 Display your loaded Modules

All Modules that are currently loaded for you can be displayed by the command:

$ module list

Note: you only have to load further Modules, if you want to use additional software packages or to change the version of an already loaded software.


3 Software job examples

The Modules installed on bwHPC systems provide job examples to help you get started using the software or submitting jobs with this software. Examples can be found via a convenient variable $FOO_EXA_DIR (for a Module called foo). It is advisable to copy the whole example folder to your $HOME directory, so you can edit those job examples.

For copying the entire job examples folder of software foo to your working directory, execute:

$ module load catogory/softwarename
$ cp -R $FOO_EXA_DIR .


4 How do Modules work?

The default shell on the bwHPC clusters is bash, so explanations and examples will be shown for bash. In general, programs cannot modify the environment of the shell they are being run from, so how can the module command do exactly that?

The module command is not a program, but a bash-function. You can view its content using

$ type module

and you will get a result like this:

$ type module
module is a function
module () 
{ 
    eval `/usr/bin/modulecmd bash $*`
}

In this function, modulecmd is called. Its output to stdout is then executed inside your current shell using the bash-internal eval command. As a consequence, all output that you see from the module is transmitted via stderr (output handle 2) or in some cases even stdin (output handle 0).