Difference between revisions of "Environment Modules"

From bwHPC Wiki
Jump to: navigation, search
(Unloading Modulefiles)
Line 1: Line 1:
{| style="border-style: solid; border-width: 1px"
 
! Navigation: [[BwHPC_Best_Practices_Repository|bwHPC BPR]] / [[BwUniCluster_User_Guide|bwUniCluster]]
 
|}
 
 
 
 
<!--<span style="color:red;font-size:105%;">Important note: bwUniCluster is '''not''' in production mode yet.</span>-->
 
<!--<span style="color:red;font-size:105%;">Important note: bwUniCluster is '''not''' in production mode yet.</span>-->
   
Line 9: Line 4:
   
 
The usage of compilers, libraries and software packages requires by default users to set up
 
The usage of compilers, libraries and software packages requires by default users to set up
manually their session environment.
+
manually their session environment. The bwHPC clusters (such as [[bwUniCluster]]) provide users the possibility to load and unload ''complete environments''
 
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
 
for compilers, libraries and software packages by single commands. Because of the
convenient modularity this software is called ''Environment Modules''.
+
convenient modularity this package is called ''Environment Modules'', or short '''Modules'''.
   
   
  +
<!--{| align="right" {{Table|width=40%}} -->
  +
{|{{Softwarebox}}
  +
|-
  +
! colspan="2" style="text-align:center" | Modules
  +
<!--
  +
|-
  +
| module load
  +
| category/name
  +
-->
  +
|-
  +
| License
  +
| GPL
  +
|-
  +
| Links
  +
| http://modules.sourceforge.net/
  +
|
  +
|}
  +
  +
<!--
 
{| style="width: 100%; border-spacing: 5px;"
 
{| style="width: 100%; border-spacing: 5px;"
 
| style="text-align:left; color:#000;vertical-align:top;" |__TOC__
 
| style="text-align:left; color:#000;vertical-align:top;" |__TOC__
Line 21: Line 33:
 
|-
 
|-
 
|}
 
|}
  +
-->
   
   
= Environment Modules =
+
= Description =
   
The ''Environment Modules'' software enables dynamic modification of your environment by the
+
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
 
use of so-called ''modulefiles''. A ''modulefile'' contains information to configure the shell
for an application. Typically, a modulefile contains instructions that alter or set 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
 
environment variables, such as PATH and MANPATH, to enable access to various installed
 
software.
 
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.
+
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.
 
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.
   
Line 47: Line 60:
   
   
  +
= Usage =
== Modulefile Help ==
 
   
  +
== Documentation ==
For help on how to use the ''Environment Modules'' software, i.e., the command ''module'',
 
  +
  +
For help on how to use ''Modules'' software, i.e., the command '''module''',
 
execute:
 
execute:
 
<pre>
 
<pre>
Line 59: Line 74:
 
</pre>
 
</pre>
   
For help on particular version of modulefiles, e.g. Intel compiler version 12.1, execute:
+
For help on particular version of ''Module'', e.g. Intel compiler version X.Y, execute:
 
<pre>
 
<pre>
$ module help compiler/intel/12.1
+
$ module help compiler/intel/X.Y
 
</pre>
 
</pre>
   
   
== Display all available modulefiles ==
+
== Display all available Modules ==
   
Available modulefiles are ''modulefiles'' that can be load by the user. A modulefile must be loaded before it provides changes to your environment, as described in the introduction to this
+
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 modulefiles on the system by executing:
+
section. You can display all available ''Modules'' on the system by executing:
 
<pre>
 
<pre>
 
$ module avail
 
$ module avail
Line 77: Line 92:
 
</pre>
 
</pre>
   
Available modulefiles can be also displayed in modes:
+
Available ''Modules'' can be also displayed in different modes, such as
* each modulefile per one line
+
* each ''Module'' per one line
 
<pre>
 
<pre>
 
$ module -t avail
 
$ module -t avail
Line 88: Line 103:
   
   
== Modulefile categories, versions and defaults ==
+
== Module categories, versions and defaults ==
   
The bwHPC clusters (such as '''''bwUniCluster''''') traditionally provide a large variety of
+
The bwHPC clusters (such as [[bwUniCluster]]) traditionally provide a large variety of
software and software versions. Therefore modulefiles are divided in category folders
+
software and software versions. Therefore ''Module'' are divided in category folders
containing subfolders of modulefiles containing modulefile versions, and must be addressed
+
containing subfolders of modulefiles again containing modulefile versions, and must be addressed
 
as follows:
 
as follows:
 
<pre>
 
<pre>
category/modulefile_name/version
+
category/softwarename/version
 
</pre>
 
</pre>
For instance the Intel compiler 12.1 belongs to the category of compilers, therefore the
+
For instance the Intel compiler X.Y belongs to the category of compilers, therefore the
modulefile ''12.1'' is placed under the category ''compiler'' and ''intel''.
+
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'''
 
In case of multiple software versions, one version will be always defined as the '''default'''
version. Modulefiles of such default software can be addressed by omitting the version number:
+
version. The ''Module'' of the default can be addressed by simply omitting the version number:
 
<pre>
 
<pre>
category/modulefile_name
+
category/softwarename
 
</pre>
 
</pre>
   
   
== Loading Modulefiles ==
+
== Finding software Modules ==
  +
You can load a modulefile in to your environment to enable easier access to software that
 
  +
Currently all bwHPC software packages are assigned to the following ''Module'' categories:
  +
<!-- add wiki category for each of those, possibly just as a link -->
  +
* [[:Category:Biology_software|bio]]
  +
* cae
  +
* [[:Category:Chemistry_software|chem]]
  +
* compiler
  +
* devel
  +
* dot
  +
* lib
  +
* [[BwHPC_BPG_for_Mathematics|math]]
  +
* mpi
  +
* numlib
  +
* phys
  +
* system
  +
* vis
  +
  +
You can selectively list software in one of those categories using, e.g. for the category "compiler"
  +
<pre>
  +
$ module avail compiler/
  +
</pre>
  +
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"
  +
<pre>
  +
$ module avail c
  +
</pre>
  +
while this would find nothing
  +
<pre>
  +
$ module avail hem
  +
</pre>
  +
  +
  +
== 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:
 
you want to use by executing:
 
<pre>
 
<pre>
$ module load category/modulefile_name/version
+
$ module load category/softwarename/version
 
</pre>
 
</pre>
 
or
 
or
 
<pre>
 
<pre>
$ module add category/modulefile_name/version
+
$ module add category/softwarename/version
 
</pre>
 
</pre>
Loading a modulefile in this manner affects your environment for the current session only.
+
Loading a ''Module'' in this manner affects ONLY your environment for the current session.
   
   
=== Modulefile conflicts ===
+
=== Loading conflicts ===
By default you can not load different versions of same software modulefile in same session. Loading for example Intel compiler version 13.1 while Intel compiler version 12.1 is loaded results in error message as follows:
+
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:
 
{| style="width: 100%; border:1px solid #d0cfcc; background:#f2f7ff;border-spacing: 2px;"
 
{| style="width: 100%; border:1px solid #d0cfcc; background:#f2f7ff;border-spacing: 2px;"
 
| style="width:280px; text-align:center; white-space:nowrap; color:#000;" |
 
| style="width:280px; text-align:center; white-space:nowrap; color:#000;" |
 
<source lang="bash">
 
<source lang="bash">
ERROR:150: Module 'compiler/intel/13.1' conflicts with the currently loaded module(s) 'compiler/intel/12.1'
+
ERROR:150: Module 'compiler/intel/X' conflicts with the currently loaded module(s) 'compiler/intel/Y'
 
</source>
 
</source>
 
|}
 
|}
The solution is [[#Unloading Modulefiles|unloading]] or switching modulefiles.
+
The solution is [[#Unloading Modules|unloading]] or switching ''Modules''.
  +
   
 
=== Automatic Loading ===
 
=== Automatic Loading ===
If you frequently use one or more modulefiles that are not loaded when you log in to
+
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 modulefiles for
+
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
 
you. A method for doing this is to modify your shell startup script to include instructions to
 
load the modulefile automatically.
 
load the modulefile automatically.
   
For example, if you want to automatically load the Intel 12.1 modulefile when you log
+
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
 
in, edit your shell startup script to include the following instructions. This example assumes
 
that you use bash as your login shell. Edit the <tt>$HOME/.bashrc</tt> file as follows:
 
that you use bash as your login shell. Edit the <tt>$HOME/.bashrc</tt> file as follows:
Line 144: Line 192:
 
## if the ’module’ command is defined, $MODULESHOME will be set
 
## if the ’module’ command is defined, $MODULESHOME will be set
 
if [ -n "$MODULESHOME" ]; then
 
if [ -n "$MODULESHOME" ]; then
module load compiler/intel/12.1
+
module load compiler/intel
 
fi
 
fi
 
</source>
 
</source>
 
|}
 
|}
From now on, whenever you log in, the Intel 12.1 compiler modulefile 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.
   
  +
=== Modulefiles depending on Modulefiles ===
 
  +
=== Modules depending on Modules ===
Some software depends on libraries to be loaded to the user environment. Therefore the
 
  +
Some program ''Modules'' depend on libraries to be loaded to the user environment. Therefore the
corresponding modulefile of the software must be loaded together with the modulefiles of
 
  +
corresponding ''Modules'' of the software must be loaded together with the ''Modules'' of
 
the libraries.
 
the libraries.
   
By default such software modulefiles try to load required modulefile and modulefile versions automatically. However, automatic loading might fail if a different version of that required modulefile
+
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. [[#Modulefile conflicts|modulefile conflicts]]).
+
is already loaded (cf. [[#Loading conflicts|Loading conflicts]]).
   
   
== Unloading Modulefiles ==
+
== Unloading Modules ==
   
To unload or to remove a software module execute:
+
To unload or to remove a software ''Module'' execute:
   
 
<pre>
 
<pre>
$ module unload category/modulefile_name/version
+
$ module unload category/softwarename/version
 
</pre>
 
</pre>
   
Line 171: Line 220:
   
 
<pre>
 
<pre>
$ module remove category/modulefile_name/version
+
$ module remove category/softwarename/version
 
</pre>
 
</pre>
   
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.
+
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:
 
In order to remove all previously loaded software modules from your environment issue the following command:
 
 
<pre>
 
<pre>
 
$ module purge
 
$ module purge
 
</pre>
 
</pre>
   
  +
== Display your loaded Modulefiles ==
 
  +
== Display your loaded Modules ==
All modulefiles that are currently loaded for you can be displayed by the
 
  +
All ''Modules'' that are currently loaded for you can be displayed by the
 
command:
 
command:
 
<pre>
 
<pre>
 
$ module list
 
$ module list
 
</pre>
 
</pre>
You only have to load further modulefiles, if you want to use additional software
+
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.
 
packages or to change the version of an already loaded software.
  +
  +
  +
= 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:
  +
<pre>
  +
$ module load catogory/softwarename
  +
$ cp -R $FOO_EXA_DIR .
  +
</pre>
  +
  +
  +
= 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
  +
<pre>
  +
$ type module
  +
</pre>
  +
and you will get a result like this:
  +
<pre>
  +
$ type module
  +
module is a function
  +
module ()
  +
{
  +
eval `/usr/bin/modulecmd bash $*`
  +
}
  +
</pre>
  +
  +
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).
  +
  +
   
   
 
----
 
----
[[Category:bwHPC|User Environment]]
+
[[Category:System software]][[Category:bwUniCluster]]
[[Category:bwUniCluster|Environment Modules]]
+
<!--[[Category:bwHPC|User Environment]]
  +
[[Category:bwUniCluster|Environment Modules]]-->

Revision as of 19:07, 28 April 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:

  • bio
  • cae
  • chem
  • compiler
  • devel
  • dot
  • lib
  • math
  • mpi
  • numlib
  • phys
  • system
  • vis

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.5.2 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.5.3 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.6 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.7 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).