start:working_on_mogon:workflow_organization:setting_up_environment_modules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
start:working_on_mogon:workflow_organization:setting_up_environment_modules [2021/11/24 11:22]
jrutte02 removed
— (current)
Line 1: Line 1:
-====== Setting Up Environment (Modules) ====== 
- 
-To run jobs on MOGON, you need to set up your environment correctly. This wiki page will help you to do so. 
- 
-===== What are modulefiles or environment modules? ===== 
- 
-[[https://en.wikipedia.org/wiki/Environment_Modules_(software)|Environment modules, a.k.a modulefiles]], are a way to set up a working environment (under Linux/Unix) dynamically. HPC system administration has to be rather conservative: In order to provide a consistent environment it is not impossible to install the newest (untested) piece of software (or kernel stuff) system-wide. On the other hand the requirement to run state of the art scientific software has to be fulfilled. This is where environment modules step in rather handy: 
- 
-So, loading a particular module will set up an environment? This is mainly done by exporting [[https://en.wikipedia.org/wiki/Environment_variable|environment variables]], particularly ''PATH'' and ''(LD)_LIBRARY_PATH'' and others. Usually modulefiles contain code to sanitize the setup, e.g. reporting conflicts with other loaded modules or deprecation warnings. 
- 
-======= Lmod: A New Environment Module System ======= 
- 
-<blockquote> 
-Lmod is a Lua based module system that easily handles the MODULEPATH Hierarchical problem. Environment Modules provide a convenient way to dynamically change the users’ environment through modulefiles. This includes easily adding or removing directories to the PATH environment variable. Modulefiles for Library packages provide environment variables that specify where the library and header files can be found. 
- 
-<cite>Lmod [[https://lmod.readthedocs.io/en/latest/|Documentation]]</cite> 
-</blockquote> 
- 
- 
- 
-==== Lmod Opt-Out ==== 
- 
-Create the file ''.nolmod'' in your home directory with the following command in order to use Lmod at the **next** login: 
- 
-<code bash> 
-touch ~/.nolmod 
-</code> 
- 
-====== Working with Lmod ====== 
- 
-==== Frequently Used Commands ==== 
- 
-^ Command         ^ Description                                ^ Comment ^ 
-| ''module help''     | get a list of all commands known to module |         | 
-| ''module avail''    | find out what modules are available        |         | 
-| ''module list''     | list loaded modules                        |         | 
-| ''module load/add'' | loads modules/packages                             | 
-| ''module unload''   | unloads modules/packages                           | 
-| ''module swap''     | change from one compiler to another        | ''module swap gcc intel''| 
-| ''module reset''    | go back to an initial set of modules               | 
- 
- 
-===== Finding Modules ===== 
- 
-In many cases there are several versions of the same compiler/program installed. You have to check that your desired version is available. 
- 
-==== module avail ==== 
- 
-You can get an overview of **all available** modules using the command 
- 
-<code shell> 
-module avail 
-</code> 
-or 
-<code shell> 
-module av 
-</code> 
- 
-You can use the search capabilities to refine your search, e.g.: 
- 
-<code bash> 
-module av mathematica 
-</code> 
- 
-gives 
- 
-<code shell> 
-JGU HPC Modules 
- 
-------------------- /cluster/easybuild/broadwell/modules/all ------------------- 
-   math/Mathematica/11.1.1    math/Mathematica/12.2.0 (D) 
- 
-  Where: 
-   D:  Default Module 
-Questions? contact us at hpc@uni-mainz.de 
-yet more ... 
-</code> 
- 
- 
-==== Area Specific Modules ==== 
- 
-EasyBuild, our software installation framework provides prefixes – at least the way we install software – for modulefiles: bio, chem and phys. This classification is a bit arbitrary at times, but you can search for the respective strings and look whether your desired application is already available. 
- 
-Other classes include lib and compiler. Of particular relevance is sometimes the lang category, e.g. for providing scripting languages with their correct version (see for example the entries on Python, R and BioConductor and Perl). 
- 
-For example with: 
-<code bash> 
-module avail/av phys 
-</code> 
- 
-you get all the Modules in ''phys'' 
- 
-<code shell> 
-[joe_user@login23 ~]$ module avail phys 
-JGU HPC Modules 
- 
-------------------- /cluster/easybuild/broadwell/modules/all ------------------- 
-   phys/ESPResSo++/2.0.1-foss-2018b 
-   phys/HOOMD/2.5.1-fosscuda-2019b-double 
-   phys/HOOMD/2.9.1-fosscuda-2019b-double 
-   phys/HOOMD/2.9.1-fosscuda-2019b-single 
-   phys/HOOMD/2.9.6-fosscuda-2019b-single 
-   phys/HOOMD/2.9.6-fosscuda-2020b-double 
-   phys/HOOMD/2.9.6-fosscuda-2020b-single (D) 
-   phys/UDUNITS/2.2.26-GCCcore-8.3.0 
-   phys/UDUNITS/2.2.26                    (D) 
- 
-  Where: 
-   D:  Default Module 
-Questions? contact us at hpc@uni-mainz.de 
-yet more ... 
-</code> 
- 
-==== module spider ==== 
- 
-The command ''module spider'' lists all modules that can be loaded on MOGON. 
- 
-<code shell> 
-module spider mathematica 
-</code> 
- 
-gives 
- 
-<code shell> 
----------------------------------------------------------------------------- 
-  math/Mathematica: 
----------------------------------------------------------------------------- 
-    Description: 
-      Mathematica is a computational software program used in many 
-      scientific, engineering, mathematical and computing fields. 
- 
-     Versions: 
-        math/Mathematica/11.1.1 
-        math/Mathematica/12.2.0 
- 
----------------------------------------------------------------------------- 
-  For detailed information about a specific "math/Mathematica" package (including how to load the modules) use the module's full name. 
-  Note that names that have a trailing (E) are extensions provided by other modules. 
-  For example: 
- 
-     $ module spider math/Mathematica/12.2.0 
----------------------------------------------------------------------------- 
-</code> 
- 
-===== Loading Modules ===== 
- 
-Now, knowing the modules that are available you can go on by loading the module(s) you need. This will happen using the command ''module load [module]'' or ''module add [module]''. 
- 
-Example: Maybe you want to load gcc (version 10.2.0) and OpenMPI, so you would do 
- 
-<code bash> 
-module load mpi/OpenMPI/4.0.5-GCC-10.2.0 
-</code> 
- 
-That's all - OpenMPI (version 4.0.5) was compiled with gcc 10.2.0 as the version string indicates, but mpicc depends on the specific compiler (and libraries), hence gcc is also provided in the correct version. 
- 
-===== Listing active Modules ===== 
- 
-<code shell> 
-module list 
-</code> 
-From the example above: 
- 
-<code shell> 
-Currently Loaded Modules: 
-  1) compiler/GCCcore/10.2.0        4) lib/libfabric/1.11.0-GCCcore-10.2.0 
-  2) compiler/GCC/10.2.0            5) lib/PMIx/3.1.5-GCCcore-10.2.0 
-  3) lib/UCX/1.9.0-GCCcore-10.2.0   6) mpi/OpenMPI/4.0.5-GCC-10.2.0 
-</code> 
- 
-===== Unload Modules ===== 
- 
-To expel a specific module you can use the command 
- 
-<code shell> 
-module rm [module] 
-</code> 
- 
-or 
- 
-<code shell> 
-module unload [module] 
-</code> 
- 
- If you want to unload **all** your loaded modules, use 
- 
-<code shell> 
-module purge 
-</code> 
- 
-===== Displaying contents of a Module ===== 
- 
-<code bash> 
-module show 
-</code> 
- 
-===== ml - A convenient Tool ===== 
- 
-<blockquote> 
- 
-For those of you who can’t type the //mdoule//, moduel, err //module// command correctly, Lmod has a tool for you. With ''ml'' you won’t have to type the module command again. The two most common commands are ''module list'' and ''module load <something>'' and ''ml'' does both: 
-<cite>Lmod [[https://lmod.readthedocs.io/en/latest/|Documentation]]</cite> 
-</blockquote> 
- 
- 
-<code bash> 
-ml 
-</code> 
- 
-means ''module list''. And 
- 
-<code bash> 
-ml foo 
-</code> 
- 
-means ''module load foo''. 
- 
-<code bash> 
-ml -bar 
-</code> 
- 
-means ''module unload bar'' It is not surprising that these can be combined: 
- 
-<code bash> 
-ml foo -bar 
-</code> 
- 
-means ''module unload bar''; ''module load foo''. 
- 
-You can do **all** the module commands: 
- 
-<code bash> 
-ml spider 
-ml avail 
-ml show foo 
-</code> 
- 
-===== User Collections ===== 
- 
-User defined initial list of login modules 
- 
-<code bash> 
-module load module1 module2 ... 
-</code> 
- 
-On MOGON, users can create as many collections as they like. You can save to a nemed collection with: 
- 
-<code bash> 
-module save <collection_name> 
-</code> 
- 
-The collection is restored with: 
- 
-<code bash> 
-module restore <collection_name> 
-</code> 
- 
-You can display the contents of a name collection with 
- 
-<code bash> 
-module describe <collection_name> 
-</code> 
- 
-Use the following command to list the collections you already have: 
- 
-<code bash> 
-module savelist 
-</code> 
- 
-Finally, you can deactivate a collection with: 
- 
-<code bash> 
-module disable <collection_name> 
-</code> 
- 
-If no ''<collection_name>'' is specified, the default is disabled. Note that the collection is not removed, only renamed. If you disable the collection ''foo'', the file ''foo'' is renamed to ''foo~''. To restore the foo collection, you must do the following: 
- 
-<code bash> 
-cd ~/.lmod.d; mv foo~ foo 
-</code> 
- 
- 
-====== Working with Environment Modules ====== 
- 
-In order to use the old Environment Modules system, the file ''~/.lmod'' **should not** be present in your home directory. 
- 
-===== List of useful module commands ===== 
- 
-Before we really start, the most frequently used commands at a glance: 
- 
-^ Command ^ Description ^ 
-| ''module -h|help'' | shows an overview of all available commands | 
-| ''module avail'' | shows all available modules | 
-| ''module load|add [module]'' | loads the module [module] | 
-| ''module list'' | shows all loaded modules | 
-| ''module rm|unload [module]'' | unloads the module [module] | 
-| ''module purge'' | unloads all loaded modules | 
- 
-===== Show modules ===== 
- 
-In many cases there are several versions of the same compiler/program installed. You have to check that your desired version is available. 
-Yo can get an overview of all available modules using the command ''module avail'' ((In the past we had a dynamic list of available modulefiles linked, here. This list has been removed, because it was impossible to keep track of the changed settings on two clusters.)). 
- 
-As ''module'' reports on standard error, a grep for a particular module can be done like: 
-<code bash> 
-$ module avail |& grep <your_module_you_are_looking_for> 
-</code> 
- 
-===== Area Specific Modules ===== 
- 
-[[https://easybuilders.github.io/easybuild/|EasyBuild]], our software installation framework provides prefixes -- at least the way we install software -- for modulefiles: ''bio'', ''chem'' and ''phys''. This classification is a bit arbitrary at times, but you can search for the respective strings and look whether your desired application is already available. 
- 
-Other classes include ''lib'' and ''compiler''. Of particular relevance is sometimes the ''lang'' category, e.g. for providing scripting languages with their correct version (see for example the entries on [[:start:development:scripting_languages:python|Python]], [[:start:development:scripting_languages:r_bio|R and BioConductor]] and [[:start:development:scripting_languages:perl|Perl]]). 
- 
-===== Loading modules ===== 
- 
-Now, knowing the modules that are available you can go on by loading the module(s) you need. This will happen using the command ''module load [module]'' or ''module add [module]'' ((They are equal. It's yours to chose which you like more)). 
- 
-Example: 
-Maybe you want to load gcc (version 6.3.0) and OpenMPI, so you would do: 
-<code bash> 
-$ module load mpi/OpenMPI/2.0.2-GCC-6.3.0 
-</code> 
- 
-That's all - OpenMPI (version 2.0.2) was compiled with gcc 6.3.0 as the version string indicates, but ''mpicc'' depends on the specific compiler (and libraries), hence gcc is also provided in the correct version. 
- 
-<callout type="warning" icon="true"> 
-We strongly suggest to avoid loading modules in your ''.bashrc''-file, because we frequently observed that this leads to conflicting environments in the long run. Alternatives are: 
-  * Loading modules in submission scripts and 
-  * sourcing environment setup scripts interactively, depending on a particular workflow. 
-</callout> 
-<callout type="info" icon="true"> 
-Which module is the right?  
-  * You sometimes see ''module load <category>/<entry>'' -- not followed by a version string. This will take the most recent version (alphabetically).  
-  * It is sufficient to load one module per application/library/scripting language. 
-  * If in doubt contact the HPC-team. 
-</callout> 
- 
- 
-===== Listing active modules ===== 
- 
-If you want to check your loaded modules, simply use ''module list''. 
- 
-From the example above: 
-<code bash> 
-$ module list 
-Currently Loaded Modulefiles: 
-  1) compiler/GCCcore/6.3.0        3) mpi/OpenMPI/2.0.2-GCC-6.3.0 
-  2) compiler/GCC/6.3.0 
-</code> 
- 
-===== Unload modules ===== 
- 
-To expel a specific module you can use the command ''module rm [module]'' or ''module unload [module]''. 
-If you want to unload all your loaded modules, use ''module purge''. 
- 
-Example: 
-<code bash> 
-$ module unload compiler/GCCcore/6.3.0 
-$ module purge 
-</code> 
-