Modules: Tutorial - nthu-ioa/cluster GitHub Wiki

Quick tutorial on module commands

All commands to Modules look like module {command}. Most users will only use four commands: module list, module avail, module load and module unload.

We'll look at examples for the module gcc, which provides access to the GNU compilers.

module list shows a list of the modules that have been loaded in the current environment. When you first log in, by default, no modules are loaded.

[apcooper@fomalhaut ~]$ module list
No Modulefiles Currently Loaded.

module avail shows a list of the modules that can be loaded (if you try this on fomalhaut, you will see many more modules than shown in this example..

[apcooper@fomalhaut ~]$ module avail
---------- /cluster/software/modulefiles ----------
gcc/7.4.0  gcc/8.3.0    

module load gcc/8.3.0 loads version 8.3.0 of the GNU compilers.

[apcooper@fomalhaut ~]$ module load gcc/8.3.0
[apcooper@fomalhaut ~]$ module list
Currently Loaded Modulefiles:
 1) gcc/8.3.0  

module load gcc/7.4.0 loads version 7.4.0 of the GNU compilers. However, if another version of gcc has already been loaded, Modules will complain, because these two modules conflict with each other.

[apcooper@fomalhaut ~]$ module load gcc/8.3.0
[apcooper@fomalhaut ~]$ module load gcc/7.4.0
Loading gcc/7.4.0
  ERROR: gcc/7.4.0 cannot be loaded due to a conflict.
    HINT: Might try "module unload gcc" first.

Modules can be unloaded:

[apcooper@fomalhaut ~]$ module unload gcc
[apcooper@fomalhaut ~]$ module load gcc/7.4.0
[apcooper@fomalhaut ~]$ module list
Currently Loaded Modulefiles:
 1) gcc/7.4.0  

Setting up your working environment

Without modules, the usual way to set up the shell environment is with commands like export in files like ~/.bashrc and ~/.profile. The shell itself usually sources some 'system default' variables from other files, like /etc/profile.

With modules, all the manipulation of environment variables can be replaced with a such simpler sequence module load some_module commands, in the same files. All we do system-wide in /etc/profile is to set up the module system itself. We leave it up to users to decide which modules to load when they start a new shell session, and how they want to load those modules.