Utiliser des modules/en: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(Fixed typo modules->modules in English version)
No edit summary
 
(77 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages />
<languages />
Compute Canada servers can execute all software that runs under Linux. In the simplest case, the software you need will already be installed on one of the compute servers. It will then be accessible in the form of a "module". If this is not the case, you can either ask our staff to install it for you, or do it yourself.  
Our servers can execute all software that runs under Linux. In the simplest case, the software you need will already be installed on one of the compute servers. It will then be accessible in the form of a "module". If this is not the case, you can either ask our staff to install it for you, or do it yourself.  


Modules are configuration files that contain instructions for modifying your software environment. This modular architecture allows multiple versions of the same application to be installed without conflict. For new Compute Canada servers, modules are managed with the [https://www.tacc.utexas.edu/research-development/tacc-projects/lmod Lmod] tool developed at [https://www.tacc.utexas.edu/ TACC]. This tool replaces [http://modules.sourceforge.net ''Environment Modules''], which is used on most legacy servers. If you are familiar with this system you should not be too disoriented since "Lmod" was designed to be very similar to "Environment Modules". Refer to the [[#Lmod vs Environment Modules]] section for the main differences between the two systems.  
Modules are configuration files that contain instructions for modifying your software environment. This modular architecture allows multiple versions of the same application to be installed without conflict. For new servers, modules are managed with the [https://www.tacc.utexas.edu/research-development/tacc-projects/lmod Lmod] tool developed at [https://www.tacc.utexas.edu/ TACC]. This tool replaces [http://modules.sourceforge.net ''Environment Modules''], which is used on most legacy servers. If you are familiar with this system you should not be too disoriented since "Lmod" was designed to be very similar to "Environment Modules". Refer to the [[#Lmod vs Environment Modules]] section for the main differences between the two systems.  


A "modulefile" contains the information needed to make an application or library available in the user's login session. Typically a module file contains instructions that modify or initialize environment variables such as <code>PATH</code> and <code>LD_LIBRARY_PATH</code> in order to use different installed programs.
A "modulefile" contains the information needed to make an application or library available in the user's login session. Typically a module file contains instructions that modify or initialize environment variables such as <code>PATH</code> and <code>LD_LIBRARY_PATH</code> in order to use different installed programs. Note that the simple fact of loading a module doesn't execute the software in question. To learn the name of the program binary or the syntax for its use, you should read the documentation for this software. By using the <tt>module</tt> command, you shouldn't normally need to know the exact location or path of the software or library but you can nevertheless see such details about the module by means of the command <tt>module show <module-name></tt>.


= Important <code>module</code> commands =
== Important <code>module</code> commands ==
The command <code>module</code> has several subcommands. The normal syntax is
The command <code>module</code> has several subcommands. The normal syntax is
{{Command | module command [other options]}}
{{Command | module command [other options]}}


To see a list of available sub-commands use
To see a list of available sub-commands, use
{{Command|module help}}
{{Command|module help}}


== Sub-command <code>avail</code> ==
=== Sub-command <code>spider</code> ===
To list the modules available on a given system, use
The <code>spider</code> sub-command searches the complete tree of all modules in the current [[Standard software environments|standard software environment]] and displays it.
{{Command|module avail}}
 
You can obtain a list of modules available for a particular library or tool, for example modules related to <code>openmpi</code>:
{{Command|module avail openmpi}}
 
Note that the <code>module avail</code> command may not list some modules that are incompatible with the modules you have loaded. To see the complete list of all modules use the <code>spider</code> sub-command documented below.
 
== Sub-command <code>spider</code> (Lmod only) ==
The <code>spider</code> sub-command searches the complete tree of all modules and displays it.
{{Command|module spider}}
{{Command|module spider}}


Line 31: Line 22:


If you specify the name of the application along with a version number, for example with
If you specify the name of the application along with a version number, for example with
{{Command|module spider openmpi/1.8.4}}
{{Command|module spider openmpi/4.0.3}}
this will display a list of the modules you must load in order to access this version.
this will display a list of the modules you must load in order to access this version.


== Sub-command <code>list</code> ==
=== Sub-command <code>avail</code> ===
The sub-command <code>list</code> lists the modules that are currently loaded in your environment.
To list the modules you can load, use
{{Command|module avail}}
 
You can obtain a list of modules available for a particular library or tool, for example modules related to <code>openmpi</code>:
{{Command|module avail openmpi}}
 
Note that the <code>module avail</code> command may not list some modules that are incompatible with the modules you have loaded. To see the list of all modules other than those you've loaded and which are available for you, use the <code>spider</code> sub-command documented above.
 
 
=== Sub-command <code>list</code> ===
The sub-command '''<code>list</code>''' lists the modules that are currently loaded in your environment.
{{Command|module list}}
{{Command|module list}}


== Sub-command <code>load</code> ==
=== Sub-command <code>load</code> ===
The sub-command <code>load</code> lets you load a given module. For example,
The sub-command '''<code>load</code>''' lets you load a given module. For example,
{{Command|module load gcc/4.8}}
{{Command|module load gcc/9.3}}
could let you access the GCC compilers, version 4.8.  
allows you to access the GCC compiler suite, version 9.3.  


You can load more than one module with a single command. For example,
You can load more than one module with a single command. For example,
{{Command|module load gcc/4.8 mpi/openmpi/1.8.4}}
{{Command|module load gcc/9.3 openmpi/4.0}}
will load at the same time the GCC 4.8 compilers and the Open MPI library 1.8.4, compiled for GCC.  
will load at the same time the GCC 9.3 compilers and the Open MPI library 4.0, compiled for GCC.  


If you load a module that is incompatible with one you already have loaded, Lmod will tell you that it has replaced the old module with a new one. This can occur especially for compilers and MPI implementations.  
If you load a module that is incompatible with one you already have loaded, Lmod will tell you that it has replaced the old module with a new one. This can occur especially for compilers and MPI implementations.


== Sub-command <code>unload</code> ==
=== Sub-command <code>unload</code> ===
After the <code>load</code> sub-command, <code>unload</code> removes a module from your environment. For example,
In contrast with the '''<code>load</code>''' sub-command, '''<code>unload</code>''' removes a module from your environment. For example,
{{Command|module unload gcc/4.8}}
{{Command|module unload gcc/9.3}}
would remove the GCC 4.8 compilers from your environment.  
would remove the GCC 9.3 compiler suite from your environment.  


If you have other modules loaded that depend on this compiler, Lmod will tell you that they have been disabled.
If you have other modules loaded that depend on this compiler, Lmod will tell you that they have been disabled.


== Sub-command <code>purge</code> ==
=== Sub-command <code>purge</code> ===
The sub-command <code>purge</code> allows you to remove all the modules you have loaded in one go.
The sub-command '''<code>purge</code>''' allows you to remove all the modules you have loaded with a single command.
{{Commande|module purge}}


Some modules may be marked "sticky" (permanent) by system administrators. These will not be unloaded.
Some modules may be marked "sticky" (permanent) by system administrators. These will not be unloaded.


== Sub-commands <code>show, help</code> and <code>whatis</code> ==
=== Sub-commands <code>show, help</code> and <code>whatis</code> ===
The sub-commands <code>show, help</code> and <code>whatis</code> provide additional information about a given module. The <code>show</code> sub-command displays the entire module, <code>help</code> displays a help message, and <code>whatis</code> shows a description of the module.
The sub-commands '''<code>show</code>''', '''<code>help</code>''' and '''<code>whatis</code>''' provide additional information about a given module. The '''<code>show</code>''' sub-command displays the entire module, '''<code>help</code>''' displays a help message, and '''<code>whatis</code>''' shows a description of the module.


== Sub-command <code>apropos</code> or <code>keyword</code> ==
{{Commande|module help gcc/9.3}}
The sub-commands <code>apropos</code> or <code>keyword</code> allow you to search for a keyword in all modules. If you don't know which module is appropriate for your calculation, you can search the description.


= Loading modules automatically =
=== Sub-command <code>apropos</code> or <code>keyword</code> ===
The sub-commands <code>apropos</code> or <code>keyword</code> allow you to search for a keyword in all modules. If you don't know which module is appropriate for your calculation, you can search by description.
 
== Loading modules automatically ==
'''We advise against loading modules automatically in your .bashrc.''' Instead we recommend that you load modules only when required, for example in your job scripts. To facilitate the repeated loading of a large number of modules we recommend you use a module collection.  
'''We advise against loading modules automatically in your .bashrc.''' Instead we recommend that you load modules only when required, for example in your job scripts. To facilitate the repeated loading of a large number of modules we recommend you use a module collection.  


= Module collections (Lmod only) =
== Module collections ==
Lmod allows you to create a collection of modules. To do so, first load the desired modules. For example:
Lmod allows you to create a collection of modules. To do so, first load the desired modules. For example:
{{Command|module load gcc/4.8 openmpi/1.8 mkl}}
{{Command|module load gcc/9.3 openmpi/4.0.3 mkl}}


Then use the <code>save</code> sub-command to save this collection:
Then use the <code>save</code> sub-command to save this collection:
{{Command|module save my_modules}}
{{Command|module save my_modules}}
The <code>my_modules</code> argument is a name you give the collection.  
The <code>my_modules</code> argument is a name you give to the collection.  


Then in a later session or in a job you can restore the collection with the command
Then in a later session or in a job you can restore the collection with the command
{{Command|module restore my_modules}}
{{Command|module restore my_modules}}


= Hidden modules =
== Hidden modules ==
Some modules are hidden. You may ignore them. They are typically modules that you don't have to load manually. They are loaded automatically based on other modules.  
Some modules are hidden. You may ignore them. They are typically modules that you don't have to load manually. They are loaded automatically based on other modules.  
= Lmod vs Environment Modules =
The main differences between the environment available to you on the new Compute Canada servers and the servers you have used in the past are as follows.


== Module hierarchy ==
== Module hierarchy ==
Most systems use a flat module structure: All modules are at the same level. This becomes problematic when many combinations of versions of different modules are available on a system. For example, if you need to use the [[FFTW]] library and the module <code>fftw</code> is available in several versions, including a version compiled with GCC 4.8 and Open MPI 1.6, you might see modules named <code>openmpi/1.6_gcc4.8</code> and <code>fftw/3.3_gcc4.8_openmpi1.6</code>. This is neither elegant nor practical. To solve this problem we use a hierarchy of modules. Rather than using the command
Many HPC clusters around the world use a flat module structure: All modules are at the same level. This becomes problematic when many combinations of versions of different modules are available on a system. For example, if you need to use the [[FFTW]] library and the module <code>fftw</code> is available in several versions, including a version compiled with GCC 9.3 and Open MPI 4.0, you might see modules named <code>openmpi/4.0_gcc9.3</code> and <code>fftw/3.8_gcc9.3_openmpi4.0</code>. This is neither elegant nor practical. To solve this problem we use a hierarchy of modules. Rather than using the command
{{Command|module load gcc/4.8 openmpi/1.6_gcc4.8 fftw/3.3_gcc4.8_openmpi1.6}}
{{Command|module load gcc/9.3 openmpi/4.0_gcc9.3 fftw/3.8_gcc9.3_openmpi4.0}}
you instead use
you instead use
{{Command|module load gcc/4.8 openmpi/1.6 fftw/3.3}}
{{Command|module load gcc/9.3 openmpi/4.0 fftw/3.8}}
This is made possible by using a module hierarchy. The <code>fftw/3.3</code> module that is loaded will not be the same one that would be loaded if you had previously loaded the Intel compilers instead of GCC.  
This is made possible by using a module hierarchy. The <code>fftw/3.8</code> module that is loaded will not be the same one that would be loaded if you had previously loaded the Intel compilers instead of GCC.  


The inconvenience of using a module hierarchy is that, since modules can have the same name, only the modules that are compatible with the "parent" modules are displayed by the <code>module avail</code> command. Loading a parent module is therefore a prerequisite to loading some modules. To get complete information, Lmod provides the <code>module spider</code> command. It scans the entire hierarchy and displays all the modules. By specifying a module and a particular version, it is then possible to see which paths in the hierarchy enable the desired module to be loaded.
The inconvenience of using a module hierarchy is that, since modules can have the same name, only the modules that are compatible with the "parent" modules are displayed by the <code>module avail</code> command. Loading a parent module is therefore a prerequisite to loading some modules. To get complete information, the module system provides the <code>module spider</code> command. It scans the entire hierarchy and displays all the modules. By specifying a module and a particular version, it is then possible to see which paths in the hierarchy enable the desired module to be loaded.


== Module collections ==
== Automatic replacement of modules ==
Module collections are an additional functionality provided by Lmod. See [[#Module collections (Lmod only)|this section]] for more details.
When the module system detects two modules of the same family, or two version of the same module, the command <code>module load</code> will automatically replace the original module with the one to be loaded. In the cases where the replaced module is a node in the module hierarchy, dependent modules will be reloaded if there are compatible versions, or deactivated otherwise.


== Only one version loaded at a time ==
== Creating modules ==  
Lmod will refuse to load two versions of the same module at the same time. For example, you cannot have versions 4.8 and 5.4 of the GCC compilers loaded at once.
For instructions about creating modules, please refer to the [http://lmod.readthedocs.io/en/latest/015_writing_modules.html official documentation].  
 
== Only one module in the same family loaded at a time ==
It is possible for administrators to specify that two modules with different names are of the same family. Lmod will refuse to load two modules of the same family. Typical examples are compiler modules (gcc, intel), MPI modules (openmpi, mvapich2), or BLAS library modules (mkl, openblas).
 
== Automatic replacement of modules ==
When Lmod detects two modules of the same family, or two version of the same module, the command <code>module load</code> will automatically replace the original module with the one to be loaded. In the cases where the replaced module is a node in the module hierarchy, dependent modules will be reloaded if there are compatible versions, or deactivated otherwise.  


== Permanent modules ==
== Using modules with ZSH or KSH ==
Lmod allows administrators to define a module as permanent or "sticky". Such a module will not be removed with the <code>module purge</code> command.
If you wish to use modules with the ZSH or KSH shell, execute the appropriate following command:
{{Command|zsh -l}}
{{Command|ksh -l}}

Latest revision as of 23:01, 29 August 2024

Other languages:

Our servers can execute all software that runs under Linux. In the simplest case, the software you need will already be installed on one of the compute servers. It will then be accessible in the form of a "module". If this is not the case, you can either ask our staff to install it for you, or do it yourself.

Modules are configuration files that contain instructions for modifying your software environment. This modular architecture allows multiple versions of the same application to be installed without conflict. For new servers, modules are managed with the Lmod tool developed at TACC. This tool replaces Environment Modules, which is used on most legacy servers. If you are familiar with this system you should not be too disoriented since "Lmod" was designed to be very similar to "Environment Modules". Refer to the #Lmod vs Environment Modules section for the main differences between the two systems.

A "modulefile" contains the information needed to make an application or library available in the user's login session. Typically a module file contains instructions that modify or initialize environment variables such as PATH and LD_LIBRARY_PATH in order to use different installed programs. Note that the simple fact of loading a module doesn't execute the software in question. To learn the name of the program binary or the syntax for its use, you should read the documentation for this software. By using the module command, you shouldn't normally need to know the exact location or path of the software or library but you can nevertheless see such details about the module by means of the command module show <module-name>.

Important module commands

The command module has several subcommands. The normal syntax is

Question.png
[name@server ~]$  module command [other options]

To see a list of available sub-commands, use

Question.png
[name@server ~]$ module help

Sub-command spider

The spider sub-command searches the complete tree of all modules in the current standard software environment and displays it.

Question.png
[name@server ~]$ module spider

If you specify the name of an application, for example with

Question.png
[name@server ~]$ module spider openmpi

this will show you a list of all available versions of the application.

If you specify the name of the application along with a version number, for example with

Question.png
[name@server ~]$ module spider openmpi/4.0.3

this will display a list of the modules you must load in order to access this version.

Sub-command avail

To list the modules you can load, use

Question.png
[name@server ~]$ module avail

You can obtain a list of modules available for a particular library or tool, for example modules related to openmpi:

Question.png
[name@server ~]$ module avail openmpi

Note that the module avail command may not list some modules that are incompatible with the modules you have loaded. To see the list of all modules other than those you've loaded and which are available for you, use the spider sub-command documented above.


Sub-command list

The sub-command list lists the modules that are currently loaded in your environment.

Question.png
[name@server ~]$ module list

Sub-command load

The sub-command load lets you load a given module. For example,

Question.png
[name@server ~]$ module load gcc/9.3

allows you to access the GCC compiler suite, version 9.3.

You can load more than one module with a single command. For example,

Question.png
[name@server ~]$ module load gcc/9.3 openmpi/4.0

will load at the same time the GCC 9.3 compilers and the Open MPI library 4.0, compiled for GCC.

If you load a module that is incompatible with one you already have loaded, Lmod will tell you that it has replaced the old module with a new one. This can occur especially for compilers and MPI implementations.

Sub-command unload

In contrast with the load sub-command, unload removes a module from your environment. For example,

Question.png
[name@server ~]$ module unload gcc/9.3

would remove the GCC 9.3 compiler suite from your environment.

If you have other modules loaded that depend on this compiler, Lmod will tell you that they have been disabled.

Sub-command purge

The sub-command purge allows you to remove all the modules you have loaded with a single command.

Question.png
[nom@serveur ~]$ module purge

Some modules may be marked "sticky" (permanent) by system administrators. These will not be unloaded.

Sub-commands show, help and whatis

The sub-commands show, help and whatis provide additional information about a given module. The show sub-command displays the entire module, help displays a help message, and whatis shows a description of the module.

Question.png
[nom@serveur ~]$ module help gcc/9.3

Sub-command apropos or keyword

The sub-commands apropos or keyword allow you to search for a keyword in all modules. If you don't know which module is appropriate for your calculation, you can search by description.

Loading modules automatically

We advise against loading modules automatically in your .bashrc. Instead we recommend that you load modules only when required, for example in your job scripts. To facilitate the repeated loading of a large number of modules we recommend you use a module collection.

Module collections

Lmod allows you to create a collection of modules. To do so, first load the desired modules. For example:

Question.png
[name@server ~]$ module load gcc/9.3 openmpi/4.0.3 mkl

Then use the save sub-command to save this collection:

Question.png
[name@server ~]$ module save my_modules

The my_modules argument is a name you give to the collection.

Then in a later session or in a job you can restore the collection with the command

Question.png
[name@server ~]$ module restore my_modules

Hidden modules

Some modules are hidden. You may ignore them. They are typically modules that you don't have to load manually. They are loaded automatically based on other modules.

Module hierarchy

Many HPC clusters around the world use a flat module structure: All modules are at the same level. This becomes problematic when many combinations of versions of different modules are available on a system. For example, if you need to use the FFTW library and the module fftw is available in several versions, including a version compiled with GCC 9.3 and Open MPI 4.0, you might see modules named openmpi/4.0_gcc9.3 and fftw/3.8_gcc9.3_openmpi4.0. This is neither elegant nor practical. To solve this problem we use a hierarchy of modules. Rather than using the command

Question.png
[name@server ~]$ module load gcc/9.3 openmpi/4.0_gcc9.3 fftw/3.8_gcc9.3_openmpi4.0

you instead use

Question.png
[name@server ~]$ module load gcc/9.3 openmpi/4.0 fftw/3.8

This is made possible by using a module hierarchy. The fftw/3.8 module that is loaded will not be the same one that would be loaded if you had previously loaded the Intel compilers instead of GCC.

The inconvenience of using a module hierarchy is that, since modules can have the same name, only the modules that are compatible with the "parent" modules are displayed by the module avail command. Loading a parent module is therefore a prerequisite to loading some modules. To get complete information, the module system provides the module spider command. It scans the entire hierarchy and displays all the modules. By specifying a module and a particular version, it is then possible to see which paths in the hierarchy enable the desired module to be loaded.

Automatic replacement of modules

When the module system detects two modules of the same family, or two version of the same module, the command module load will automatically replace the original module with the one to be loaded. In the cases where the replaced module is a node in the module hierarchy, dependent modules will be reloaded if there are compatible versions, or deactivated otherwise.

Creating modules

For instructions about creating modules, please refer to the official documentation.

Using modules with ZSH or KSH

If you wish to use modules with the ZSH or KSH shell, execute the appropriate following command:

Question.png
[name@server ~]$ zsh -l
Question.png
[name@server ~]$ ksh -l