Environment Modules: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
 
(34 intermediate revisions by 7 users not shown)
Line 5: Line 5:
The complete environments for the software package, compilers and libraries and needed by this specific version is then loaded by a single command. This happens usually in the beginning of the jobscript.
The complete environments for the software package, compilers and libraries and needed by this specific version is then loaded by a single command. This happens usually in the beginning of the jobscript.


Full documentation: <code>module help</code> and [https://lmod.readthedocs.io/en/latest/ Environment Modules Website]
= Documentation =


= Basic Usage =
For an extensive help on how to use Environment Modules, i.e., the command '''module''',
execute ''''module help'''' or use ''''man modules'''' to show manpage for the '''manual''' command.

An extensive online documentation is available on the [https://modules.readthedocs.io/en/latest/index.html Environment Modules Website].
<br>
= Usage =


== Module categories, versions and defaults ==
== Module categories, versions and defaults ==
Line 18: Line 13:


category/softwarename/version
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''.
<br>
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


e.g. if julia is installed, it is in the module <code>math/julia</code>.
Currently all bwHPC software packages are assigned to the following ''Module'' categories:

<!-- add wiki category for each of those, possibly just as a link -->
You can load it in the default version just specifying math/julia or a specific version <code> math/julia/1.11.0 </code>
* [[:Category:Biology_software|bio]]
Please note, that software may be '''hidden''' from default view using a dot in front of the version; i.e.
* [[:Category:Engineering_software|cae]]
the software is still available but not visible in <code>module avail</code> but may still be loaded,
* [[:Category:Chemistry_software|chem]]
e.g. <code> math/julia/.1.10.0 </code>.
* [[:Category:Compiler_software|compiler]]

* [[:Category:Debugger_software|devel]]
Currently all bwHPC software packages are assigned to one of the following ''Module'' categories:
* [[:Category:Mathematics_software|math]]

* mpi
<code> bio cae chem compiler devel lib math mpi numlib phys system vis </code>
* [[:Category:Numerical libraries|numlib]]
* [[:Category:Physics software|phys]]
* [[:Category:System software|system]]
* [[:Category:Visualization|vis]]


== Display and search available Modules ==
== Display and search available Modules ==
Available ''Modules'' are modulefiles that can be loaded by the user. A ''Module'' must be loaded before it provides changes to your environment. You can display all available ''Modules'' on the system by executing:
Available ''Modules'' are modulefiles that can be loaded by the user. A ''Module'' must be loaded before it provides changes to your environment. You can display all available ''Modules'' on the system by executing:
<pre>
<pre>
$ module available
$ module avail
</pre>
</pre>

The short form the command is:
You can selectively list software in one of those categories using, e.g. for the category "compiler", or just all versions of a certain module:
<pre>
<pre>
$ module av
$ module avail compiler/
$ module avail compiler/gnu
</pre>
</pre>


== module help ==
You can selectively list software in one of those categories using, e.g. for the category "compiler"
A help message for a specific ''Module'' can be displayed with ''''module help category/softwarename/version''''.
<br>
The help message usually contains additional information about the software and points to the software website and documentation.
<pre>
<pre>
$ module avail compiler/
$ module help system/example/1.0
----------------- Module Specific Help for "system/example/1.0" ---------------------------
"This module provides a bwhpc-examples job that works on every cluster.

[... rest of the output is omitted in the Wiki for clarity ...]
</pre>
</pre>

This would list all available versions of the GCC compiler suite

== Loading Modules and Check they are loaded ==

{|style="background:#deffee; width:100%;"
|style="padding:5px; background:#cef2e0; text-align:left"|
[[Image:Attention.svg|center|25px]]
|style="padding:5px; background:#cef2e0; text-align:left"|
Don't use module load in .bashrc → see [[.bashrc Do's and Don'ts]]
|}

To load a software ''Module'' and display all loaded modules:
<pre>
<pre>
$ module avail compiler/gnu
$ module list
No Modulefiles Currently Loaded.
$ module load system/example/1.0
$ module list
Currently Loaded Modulefiles:
1) system/example/1.0
</pre>
</pre>



== Loading Modules ==
Modules make software available only in your current shell. Whenever you login in, you have to load the software again. Please do not auto-load modules in ~/.bashrc, this can lead to problems with system software or other modules you may load later.
You can load a ''Module'' software in to your environment to enable easier access to software that

you want to use by executing:
== Software job examples ==
bwHPC provides example job scripts for most installed software modules.

For a Software ''Module'' with the sofware called '''SOMESOFTWARE''', you can find the example directory by:
<pre>
<pre>
$ cd $SOMESOFTWARE_EXA_DIR
$ module load category/softwarename/version
</pre>

Copy the whole example folder to your $HOME directory, so you can edit those job examples:

<pre>
$ cd
$ mkdir softwarename_examples
$ echo $SOMESOFTWARE_EXA_DIR
# Please do not proceed if the command above does not provide any text !
# Otherwise you will start to copy all system data (the directory "/").
$ cp -r $SOMESOFTWARE_EXA_DIR/ softwarename_examples/

</pre>
</pre>

or
If your specific software isn't installed, there is a dummy software example module "system/example" present on all clusters. For this module, the process looks like this:

<pre>
<pre>
# Load the example module
$ module add category/softwarename/version
$ module load system/example/1.0

# Run example in a temporary directory
$ mkdir tmp_example_dir
$ cp -r $EXAMPLE_EXA_DIR/ softwarename_examples/
$ cd tmp_example_dir/bwhpc-examples

# Example jobscript for clusters using the SLURM batch system
sbatch examples-1.0.slurm
# Example jobscript for clusters using PBS
qsub examples-1.0.pbs

# Print the results
cat examples_result.txt
</pre>
</pre>
----
Loading a ''Module'' in this manner affects ONLY your environment for the current session.

= Additional Usage Recommendations =

=== Loading conflicts ===
=== 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:
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:
Line 105: Line 151:
<br>
<br>
<pre>
<pre>
$ module show compiler/gnu/9.2
$ module show system/example/1.0
-------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
/opt/bwhpc/common/modulefiles/compiler/gnu/9.2:
/opt/bwhpc/common/modulefiles/Core/system/example/1.0.lua:
---------------------------------------------------------------------------------------------------
whatis("A generic module containing a working bwhpc-examples job.")
setenv("EXAMPLE_VERSION","1.0")
setenv("EXAMPLE_HOME","/opt/bwhpc/common/system/example/1.0")
setenv("EXAMPLE_BIN_DIR","/opt/bwhpc/common/system/example/1.0/bin")
setenv("EXAMPLE_EXA_DIR","/opt/bwhpc/common/system/example/1.0/bwhpc-examples")
prepend_path("PATH","/opt/bwhpc/common/system/example/1.0/bin")
help([["This module provides a bwhpc-examples job that works on every cluster.
The module is used as example in the bwHPC-Wiki and therefore should be installed on every cluster,
such that users can try the commands out.

* The executable of this module can be found in the folder
$EXAMPLE_BIN_DIR
Upon loading the module, the binaries are added to PATH.

* Further documentation for using the example can be found in
https://wiki.bwhpc.de/e/Environment_Modules

* Examples are located at:
$EXAMPLE_EXA_DIR
]])


setenv GNU_VERSION 9.2.0
setenv GNU_HOME /opt/bwhpc/common/compiler/gnu/9.2.0
setenv GNU_BIN_DIR /opt/bwhpc/common/compiler/gnu/9.2.0/bin
setenv GNU_MAN_DIR /opt/bwhpc/common/compiler/gnu/9.2.0/man
setenv GNU_LIB_DIR /opt/bwhpc/common/compiler/gnu/9.2.0/lib64
setenv GNU_LIB_DIR2 /opt/bwhpc/common/compiler/gnu/9.2.0/lib
prepend-path PATH /opt/bwhpc/common/compiler/gnu/9.2.0/bin
prepend-path MANPATH /opt/bwhpc/common/compiler/gnu/9.2.0/man
prepend-path LD_LIBRARY_PATH /opt/bwhpc/common/compiler/gnu/9.2.0/lib64:/opt/bwhpc/common/compiler/gnu/9.2.0/lib
setenv CC gcc
setenv CXX g++
setenv F77 gfortran
setenv FC gfortran
setenv F90 gfortran
module-whatis GNU compiler suite version 9.2.0 (gcc, g++, gfortran, gccgo)
conflict compiler/gnu
-------------------------------------------------------------------
</pre>
</pre>


Line 136: Line 186:
is already loaded (cf. [[#Loading conflicts|Loading conflicts]]).
is already loaded (cf. [[#Loading conflicts|Loading conflicts]]).
<br>
<br>

== Display your loaded Modules ==
All ''Modules'' that are currently loaded for you can be displayed by the
command ''''module list''''.
<pre>
$ module list
No Modulefiles Currently Loaded.
$ module load compiler/gnu/9.2
$ module list
Currently Loaded Modulefiles:
1) compiler/gnu/9.2
</pre>
== Unloading Modules ==
== Unloading Modules ==
To unload or to remove a software ''Module'' execute:
To unload or to remove a software ''Module'' execute:
Line 152: Line 192:
$ module unload category/softwarename/version
$ module unload category/softwarename/version
</pre>
</pre>

or
<pre>
$ module remove category/softwarename/version
</pre>
=== Unloading all loaded modules ===
=== Unloading all loaded modules ===
In order to remove all previously loaded software modules from your environment issue the command 'module purge'.
In order to remove all previously loaded software modules from your environment issue the command 'module purge'.
Line 171: Line 208:
$
$
</pre>
</pre>

== Other Module commands ==
== Other Module commands ==
=== module whatis ===
=== module whatis ===
A short description for a specific ''Module'' can be displayed with ''''module whatis category/softwarename/version''''
A short description for a specific ''Module'' can be displayed with ''''module whatis category/softwarename/version''''
<pre>
<pre>
$ module whatis compiler/gnu/9.2
$ module whatis system/example/1.0
system/example/1.0 : A generic module containing a working bwhpc-examples job.
compiler/gnu/9.2 : GNU compiler suite version 9.2.0 (gcc, g++, gfortran, gccgo)
</pre>
</pre>
=== module help ===
A help message for a specific ''Module'' can be displayed with ''''module help category/softwarename/version''''.
<br>
The help message usually contains additional information about the software and points to the software website and documentation.
<pre>
$ module help compiler/gnu/9.2

----------- Module Specific Help for 'compiler/gnu/9.2' -----------


This module provides the GNU compiler collection version 9.2.0 via commands
[... rest of the output is omitted in the Wiki for clarity ...]
</pre>

= 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 $SWN_EXA_DIR (for a ''Module'' called '''SWN'''). It is advisable to copy the whole example folder to your $HOME directory, so you can edit those job examples.
<br>
For copying the entire job examples folder of software '''swn''' to your working directory, execute:
<pre>
$ module load catogory/softwarename
$ cp -R $SWN_EXA_DIR .
</pre>
----
[[Category:System software]][[Category:bwUniCluster|Environment Modules]][[Category:ForHLR Phase I|Environment Modules]]

Latest revision as of 13:42, 12 November 2024

Software on the bwHPC Clusters is provided as Software Environment Modules, or short Modules.

Modules make it possible to have different versions of a software installed at a the same time. The complete environments for the software package, compilers and libraries and needed by this specific version is then loaded by a single command. This happens usually in the beginning of the jobscript.

Full documentation: module help and Environment Modules Website

Basic Usage

Module categories, versions and defaults

The bwHPC clusters categorize Modules, each software can exist in different versions:

category/softwarename/version

e.g. if julia is installed, it is in the module math/julia.

You can load it in the default version just specifying math/julia or a specific version math/julia/1.11.0 Please note, that software may be hidden from default view using a dot in front of the version; i.e. the software is still available but not visible in module avail but may still be loaded, e.g. math/julia/.1.10.0 .

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

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

Display and search available Modules

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

$ module avail

You can selectively list software in one of those categories using, e.g. for the category "compiler", or just all versions of a certain module:

$ module avail compiler/
$ module avail compiler/gnu

module help

A help message for a specific Module can be displayed with 'module help category/softwarename/version'.
The help message usually contains additional information about the software and points to the software website and documentation.

$ module help system/example/1.0 
----------------- Module Specific Help for "system/example/1.0" ---------------------------
"This module provides a bwhpc-examples job that works on every cluster.

[... rest of the output is omitted in the Wiki for clarity ...]


Loading Modules and Check they are loaded

Attention.svg

Don't use module load in .bashrc → see .bashrc Do's and Don'ts

To load a software Module and display all loaded modules:

$ module list
No Modulefiles Currently Loaded.
$ module load system/example/1.0
$ module list
Currently Loaded Modulefiles:
  1) system/example/1.0


Modules make software available only in your current shell. Whenever you login in, you have to load the software again. Please do not auto-load modules in ~/.bashrc, this can lead to problems with system software or other modules you may load later.

Software job examples

bwHPC provides example job scripts for most installed software modules.

For a Software Module with the sofware called SOMESOFTWARE, you can find the example directory by:

$ cd  $SOMESOFTWARE_EXA_DIR

Copy the whole example folder to your $HOME directory, so you can edit those job examples:

$ cd
$ mkdir softwarename_examples
$ echo $SOMESOFTWARE_EXA_DIR
# Please do not proceed if the command above does not provide any text !
# Otherwise you will start to copy all system data (the directory "/").
$ cp -r $SOMESOFTWARE_EXA_DIR/ softwarename_examples/

If your specific software isn't installed, there is a dummy software example module "system/example" present on all clusters. For this module, the process looks like this:

# Load the example module
$ module load system/example/1.0

# Run example in a temporary directory
$ mkdir tmp_example_dir
$ cp -r $EXAMPLE_EXA_DIR/ softwarename_examples/
$ cd tmp_example_dir/bwhpc-examples

# Example jobscript for clusters using the SLURM batch system
sbatch examples-1.0.slurm
# Example jobscript for clusters using PBS
qsub examples-1.0.pbs

# Print the results
cat examples_result.txt

Additional Usage Recommendations

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:

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

The solution is unloading or switching Modules.

Showing the changes introduced by a Module

Loading a Module will change the environment of the current shell session. For instance the $PATH variable will be expanded by the software's binary directory. Other Module variables may even change the behavior of the current shell session or the software program(s) in a more drastic way.
Loaded Modules may also invoke an additional set of environment variables, which e.g. point to directories or destinations of documentation and examples. Their nomenclature is systematic:

Variable Pointing to
$SWN_HOME Root directory of the software package
$SWN_DOC_DIR Documentation
$SWN_EXA_DIR Examples
$SWN_BPR_URL URL of software's Wiki article
and many many more...  

with SWN being the place holder of the software Module name.
All the changes to the current shell session to be invoked by loading the Module can be reviewed using 'module show category/softwarename/version'.

$ module show system/example/1.0
---------------------------------------------------------------------------------------------------
   /opt/bwhpc/common/modulefiles/Core/system/example/1.0.lua:
---------------------------------------------------------------------------------------------------
whatis("A generic module containing a working bwhpc-examples job.")
setenv("EXAMPLE_VERSION","1.0")
setenv("EXAMPLE_HOME","/opt/bwhpc/common/system/example/1.0")
setenv("EXAMPLE_BIN_DIR","/opt/bwhpc/common/system/example/1.0/bin")
setenv("EXAMPLE_EXA_DIR","/opt/bwhpc/common/system/example/1.0/bwhpc-examples")
prepend_path("PATH","/opt/bwhpc/common/system/example/1.0/bin")
help([["This module provides a bwhpc-examples job that works on every cluster.
The module is used as example in the bwHPC-Wiki and therefore should be installed on every cluster,
such that users can try the commands out.

* The executable of this module can be found in the folder
  $EXAMPLE_BIN_DIR
  Upon loading the module, the binaries are added to PATH.

* Further documentation for using the example can be found in
  https://wiki.bwhpc.de/e/Environment_Modules

* Examples are located at:
  $EXAMPLE_EXA_DIR
]])

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).

Unloading Modules

To unload or to remove a software Module execute:

$ module unload category/softwarename/version

Unloading all loaded modules

In order to remove all previously loaded software modules from your environment issue the command 'module purge'.

$ module list
Currently Loaded Modulefiles:
  1) devel/gdb/7.7
  2) compiler/intel/14.0
  3) mpi/openmpi/1.8-intel-14.0(default)
$
$ module purge
$ module list
No Modulefiles Currently Loaded.
$ 

Other Module commands

module whatis

A short description for a specific Module can be displayed with 'module whatis category/softwarename/version'

$ module whatis system/example/1.0 
system/example/1.0  : A generic module containing a working bwhpc-examples job.