Difference between revisions of "Using Modules"

From CAC Wiki
Jump to: navigation, search
(Created page with "The Frontenac Cluster using the LMOD Module system to manage the various installed software packages. In basic terms, loading a chosen module will modify various environment v...")
 
Line 24: Line 24:
  
 
The command module has several subcommands. The normal syntax is
 
The command module has several subcommands. The normal syntax is
Question.png
 
 
 
[name@server ~]$  module command [other options]
 
[name@server ~]$  module command [other options]
  
 
To see a list of available sub-commands use
 
To see a list of available sub-commands use
[name@server ~]$ module help
+
[name@server ~]$ module help
  
 +
'''avail'''
  
 
To list the modules available on a given system, use
 
To list the modules available on a given system, use
[name@server ~]$ module avail
+
[name@server ~]$ module avail
  
 
You can obtain a list of modules available for a particular library or tool, for example modules related to openmpi:
 
You can obtain a list of modules available for a particular library or tool, for example modules related to openmpi:
Line 40: Line 39:
  
 
'''list'''
 
'''list'''
 +
 
The sub-command '''list''' lists the modules that are currently loaded in your environment.
 
The sub-command '''list''' lists the modules that are currently loaded in your environment.
 
  [name@server ~]$ module list
 
  [name@server ~]$ module list
  
 +
'''load'''
 
   [name@server ~]$ module load gcc/9.3
 
   [name@server ~]$ module load gcc/9.3
 
  could let you access the GCC compilers, version 9.3.
 
  could let you access the GCC compilers, version 9.3.
Line 53: Line 54:
 
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 unload
 
Sub-command unload
 +
 +
'''unload'''
  
 
After the load sub-command, '''unload''' removes a module from your environment. For example,
 
After the load sub-command, '''unload''' removes a module from your environment. For example,
Line 60: Line 63:
  
 
'''purge'''
 
'''purge'''
The sub-command '''purge''' allows you to remove all the modules you have loaded in one go.
+
 
 +
The sub-command '''purge''' allows you to remove all the modules you have loaded in one go.
 
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 show, help and whatis
 
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.
+
'''show, help and whatis'''
Question.png
+
  
[nom@serveur ~]$ module help gcc/9.3
+
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.
 +
[nom@serveur ~]$ module help gcc/9.3
  
Sub-command apropos or keyword
+
'''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 the description.
 
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 the description.
Loading modules automatically
+
 
 +
 
 +
'''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
 
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:
Question.png
+
[name@server ~]$ module load gcc/9.3 openmpi/4.0.3 mkl
 
+
[name@server ~]$ module load gcc/9.3 openmpi/4.0.3 mkl
+
  
 
Then use the save sub-command to save this collection:
 
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 the collection.
[name@server ~]$ module save my_modules
+
 
+
The my_modules argument is a name you give 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
+
You can then in a later session or in a job , restore the collection with the command
 +
[name@server ~]$ module restore my_modules

Revision as of 17:11, 19 December 2023

The Frontenac Cluster using the LMOD Module system to manage the various installed software packages. In basic terms, loading a chosen module will modify various environment variables like $PATH and $LIBRARY_PATH such that the software executables and libraries are more easily used.

There are hundreds of software packages already available using the module system and multiple versions of many of these packages. If you need a package that is not already available or need a newer version, please contact CAC staff. One of the most useful module commands is for searching for installed packages. This is done using the "module spider" command,

e.g. module spider python
Versions:
python/2.7.14
python/2.7.18
python/3.5.4
...

This will return the versions of python available on the cluster. Note, some versions may not run given your currently loaded software stack. You can check what other packages and versions you would need to load in order to use a given package by using the "module show" command

e.g. module spider python/2.7.14
You will need to load all module(s) on any one of the lines below before the "python/2.7.14" module is available to load.
nixpkgs/16.09

Once you find which module you want and if other modules are needed to use it, you can "load" the module(s),

[name@server ~]$ module load nixpkgs/16.09 python/2.7.14

Other Important module commands

The command module has several subcommands. The normal syntax is [name@server ~]$ module command [other options]

To see a list of available sub-commands use

[name@server ~]$ module help

avail

To list the modules available on a given system, use

[name@server ~]$ module avail

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

[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 complete list of all modules use the spider sub-command documented below.

list

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

[name@server ~]$ module list

load

 [name@server ~]$ module load gcc/9.3
could let you access the GCC compilers, version 9.3.

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

[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

unload

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

[name@server ~]$ module unload gcc/9.3
would remove the GCC 9.3 compilers from your environment.
If you have other modules loaded that depend on this compiler, Lmod will tell you that they have been disabled.

purge

The sub-command purge allows you to remove all the modules you have loaded in one go. Some modules may be marked "sticky" (permanent) by system administrators. These will not be unloaded. Sub-commands show, help and whatis

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.

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

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 the 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:

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

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

[name@server ~]$ module save my_modules
The my_modules argument is a name you give the collection.

You can then in a later session or in a job , restore the collection with the command

[name@server ~]$ module restore my_modules