Environment modules
From ALICE Documentation
Contents
Environment modules
A module is a self-contained description of a software package - it contains the settings required to run a software package and, usually, encodes required dependencies on other software packages.
There are a number of different environment module implementations commonly used on HPC systems: the two most common are TCL modules and Lmod. Both of these use similar syntax and the concepts are the same so learning to use one will allow you to use whichever is installed on the system you are using. In both implementations the module
command is used to interact with environment modules. An additional sub-command is usually added to the command to specify what you want to do. For a list of sub-commands you can use module -h
or module help
. As for all commands, you can access the full help on the man pages with man module
.
List of currently loaded modules
On login, you usually start out with a default set of modules.
The module list
command shows which modules you currently have loaded in your environment. This is what you will most likely see after logging into ALICE.
[me@nodelogin02~]$ module list Currently Loaded Modules: 1) shared 2) DefaultModules 3) gcc/8.2.0 4) slurm/19.05.1
You can see that by default the module for Slurm and the gcc compiler is loaded. The number behind the slash sign represent the version number.
List available modules
To see the available modules, use module -d avail
. With the -d
option, you will only get the default versions of the modules. For various software packages, there are also older/other versions available, that might be used if necessary. You can see all version by omitting the -d
option.
[me@nodelogin02~]$ module -d avail ------------------------------------------------ /cm/shared/easybuild/modules/all ------------------------------------------------- AMUSE-Miniconda2/4.7.10 VTK/8.2.0-foss-2019b-Python-3.7.4 AMUSE-VADER/12.0.0-foss-2018a-Python-2.7.14 WebKitGTK+/2.24.1-GCC-8.2.0-2.31.1 AMUSE/12.0.0-foss-2018a-Python-2.7.14 X11/20190717-GCCcore-8.3.0 ATK/2.32.0-GCCcore-8.2.0 XML-Parser/2.44_01-GCCcore-7.3.0-Perl-5.28.0 Autoconf/2.69-GCCcore-8.3.0 XZ/5.2.4-GCCcore-8.3.0 Automake/1.16.1-GCCcore-8.3.0 Yasm/1.3.0-GCCcore-8.3.0 Autotools/20180311-GCCcore-8.3.0 ZeroMQ/4.3.2-GCCcore-8.2.0 Bazel/0.20.0-GCCcore-8.2.0 amuse-framework/12.0.0-foss-2018a-Python-2.7.14 Bison/3.3.2 at-spi2-atk/2.32.0-GCCcore-8.2.0 Boost.Python/1.67.0-foss-2018b-Python-3.6.6 at-spi2-core/2.32.0-GCCcore-8.2.0 Boost/1.71.0-gompi-2019b binutils/2.32 etc etc etc .......
If you are searching for a specific software package or tool you can search for the full module name like this:
[me@nodelogin02~]$ module avail python ---------------------------------------- /cm/shared/easybuild/modules/all ----------------------------------------- AMUSE-GPU/12.0.0-foss-2018a-Python-2.7.14 AMUSE-VADER/12.0.0-foss-2018a-Python-2.7.14 AMUSE/12.0.0-foss-2018a-Python-2.7.14 AMUSE/13.1.0-foss-2018a-Python-3.6.4 (D) Biopython/1.71-foss-2018a-Python-2.7.14 Biopython/1.73-foss-2019a Biopython/1.75-foss-2019b-Python-3.7.4 (D) Boost.Python/1.67.0-foss-2018b-Python-3.6.6 CGAL/4.11.1-foss-2018b-Python-3.6.6 CONCOCT/1.1.0-foss-2019a-Python-2.7.15 CheckM/1.0.18-foss-2019a-Python-2.7.15 Cython/0.25.2-foss-2018a-Python-2.7.14 Cython/0.25.2-foss-2018a-Python-3.6.4 Cython/0.29.3-foss-2019a-Python-3.7.2 (D) DAS_Tool/1.1.1-foss-2019a-R-3.6.0-Python-3.7.2 Docutils/0.9.1-foss-2018a-Python-2.7.14 Docutils/0.9.1-foss-2018a-Python-3.6.4 (D) GObject-Introspection/1.60.1-GCCcore-8.2.0-Python-3.7.2 IPython/5.7.0-foss-2018a-Python-2.7.14 IPython/6.4.0-foss-2018a-Python-3.6.4 IPython/7.7.0-foss-2019a-Python-3.7.2 (D) Keras/2.2.4-foss-2019a-Python-3.7.2 Mako/1.0.7-foss-2017b-Python-2.7.14 Mako/1.0.7-foss-2018a-Python-2.7.14 Mako/1.0.7-foss-2018b-Python-2.7.15 Meson/0.50.0-GCCcore-8.2.0-Python-3.7.2 Meson/0.51.2-GCCcore-8.3.0-Python-3.7.4 (D) MultiQC/1.7-foss-2018b-Python-3.6.6 NLTK/3.2.4-foss-2018a-Python-3.6.4 NLTK/3.2.4-foss-2019a-Python-3.7.2 (D) PyCairo/1.18.0-foss-2018b-Python-3.6.6 PyTorch/1.3.1-fosscuda-2019b-Python-3.7.4 PyYAML/3.13-foss-2018b-Python-3.6.6 Python/2.7.14-foss-2017b Python/2.7.14-foss-2018a Python/2.7.14-GCCcore-6.4.0-bare Python/2.7.15-foss-2018b Python/2.7.15-GCCcore-7.3.0-bare Python/2.7.15-GCCcore-8.2.0 Python/2.7.16-GCCcore-8.3.0 Python/3.6.4-foss-2018a Python/3.6.6-foss-2018b Python/3.7.2-GCCcore-8.2.0 Python/3.7.4-GCCcore-8.3.0 (D) etc etc etc .......
In the above output, you can see that there are modules with the flag "(D)". This indicates that this is the default module for a software package for which modules for different versions exists.
If you want to get more information about a specific module, you can use the whatis
sub-command:
[me@nodelogin02~]$ module whatis Python/3.7.4-GCCcore-8.3.0 Python/3.7.4-GCCcore-8.3.0 : Description: Python is a programming language that lets you work more quickly and integrate your systems more effectively. Python/3.7.4-GCCcore-8.3.0 : Homepage: https://python.org/ Python/3.7.4-GCCcore-8.3.0 : URL: https://python.org/ Python/3.7.4-GCCcore-8.3.0 : Extensions: alabaster-0.7.12, asn1crypto-0.24.0, atomicwrites-1.3.0, attrs-19.1.0, Babel- 2.7.0, bcrypt-3.1.7, bitstring-3.1.6, blist-1.3.6, certifi-2019.9.11, cffi-1.12.3, chardet-3.0.4, Click-7.0, cryptography-2.7, Cython-0.29.13, deap-1.3.0, decorator-4.4.0, docopt-0.6.2, docutils-0.15.2, ecdsa-0.13.2, future-0.17.1, idna-2.8, imagesize-1.1.0, importlib_metadata-0.22, ipaddress-1.0.22, Jinja2-2.10.1, joblib-0.13.2, liac-arff-2.4.0, MarkupSafe-1.1.1, mock-3.0.5, more-itertools-7.2.0, netaddr-0.7.19, netifaces- 0.10.9, nose-1.3.7, packaging-19.1, paramiko-2.6.0, pathlib2-2.3.4, paycheck-1.0.2, pbr-5.4.3, pip-19.2.3, pluggy-0.13.0, psutil-5.6.3, py-1.8.0, py_expression_eval-0.3.9, pyasn1-0.4.7, pycparser-2.19, pycrypto-2.6.1, Pygments-2.4.2, PyNaCl-1.3.0, pyparsing-2.4.2, pytest-5.1.2, python- dateutil-2.8.0, pytz-2019.2, requests-2.22.0, scandir-1.10.0, setuptools-41.2.0, setuptools_scm-3.3.3, six-1.12.0, snowballstemmer-1.9.1, Sphinx- 2.2.0, sphinxcontrib-applehelp-1.0.1, sphinxcontrib-devhelp-1.0.1, sphinxcontrib-htmlhelp-1.0.2, sphinxcontrib-jsmath-1.0.1, sphinxcontrib-qthelp- 1.0.2, sphinxcontrib-serializinghtml-1.1.3, sphinxcontrib-websupport-1.1.2, tabulate-0.8.3, ujson-1.35, urllib3-1.25.3, virtualenv-16.7.5, wcwidth-0.1.7, wheel-0.33.6, xlrd-1.2.0, zipp-0.6.0
Load modules
To load a software module, use module load
. In the example below, we will use Python 3.
Initially, Python 3 is not loaded and therefore not available for use. We can test this by using the command which
that looks for programs the same way that Bash does. We can use it to tell us where a particular piece of software is stored.
[me@nodelogin01~]$ which python3 /usr/bin/which: no python3 in (/cm/shared/apps/slurm/18.08.4/sbin:/cm/shared/apps/slurm/18.08.4/bin:/cm/local/apps/gcc/8.2.0/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/me/.local/bin:/home/me/bin)
We can load the python3
command with module load
:
[me@nodelogin01 ~]$ module load Python/3.7.2-GCCcore-8.2.0 [me@nodelogin01 ~]$ which python3 /cm/shared/easybuild/software/Python/3.7.4-GCCcore-8.3.0/bin/python3
So what just happened? To understand the output, first we need to understand the nature of the $PATH
environment variable. $PATH
is a special environment variable that controls where a Linux operating system (OS) looks for software. Specifically $PATH
is a list of directories (separated by :
) that the OS searches through for a command. As with all environment variables, we can print it using echo
.
[me@nodelogin01 ~]$ echo $PATH /cm/shared/easybuild/software/Python/3.7.2-GCCcore-8.2.0/bin:/cm/shared/easybuild/software/XZ/5.2.4-GCCcore- 8.2.0/bin:/cm/shared/easybuild/software/SQLite/3.27.2-GCCcore-8.2.0/bin:/cm/shared/easybuild/software/Tcl/8.6.9-GCCcore-8.2.0/bin:/cm/shared/easybuild/software/libreadline/8.0-GCCcore-8.2.0/bin:/cm/shared/easybuild/software/ncurses/6.1-GCCcore-8.2.0/bin:/cm/shared/easybuild/software/bzip2/1.0.6- GCCcore-8.2.0/bin:/cm/shared/easybuild/software/GCCcore/8.2.0/bin:/cm/shared/apps/slurm/19.05.1/sbin:/cm/shared/apps/slurm/19.05.1/bin:/cm/local/apps/gcc/8.2.0/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/me/.local/bin:/home/me/bin
You will notice a similarity to the output of the which
command. In this case, there’s only one difference: the /cm/shared/easybuild/software/Python/3.7.2-GCCcore-8.2.0/bin
directory at the beginning.
When we used module load Python/3.7.2-GCCcore-8.2.0
, it added this directory to the beginning of our $PATH
. Let us examine what is there:
[me@nodelogin01 ~]$ ls /cm/shared/easybuild/software/Python/3.7.2-GCCcore-8.2.0/bin 2to3 futurize pip pytest python3-config rst2odt_prepstyles.py sphinx-apidoc 2to3-3.7 idle3 pip3 py.test pyvenv rst2odt.py sphinx-autogen chardetect idle3.7 pip3.7 python pyvenv-3.7 rst2pseudoxml.py sphinx-build cygdb netaddr pybabel python3 rst2html4.py rst2s5.py sphinx-quickstart cython nosetests __pycache__ python3.7 rst2html5.py rst2xetex.py tabulate cythonize nosetests-3.7 pydoc3 python3.7-config rst2html.py rst2xml.py virtualenv easy_install pasteurize pydoc3.7 python3.7m rst2latex.py rstpep2html.py wheel easy_install-3.7 pbr pygmentize python3.7m-config rst2man.py runxlrd.py
Taking this to its conclusion, module load
adds software to your $PATH
. It “loads” software.
A special note on this, module load
will also load required software dependencies. If you compare the output below with what you had when you first logged in to ALICE, you will notice several other modules have been load automatically, because the Python module depends on them.
[me@nodelogin01 ~]$ module list Currently Loaded Modules: 1) shared 5) GCCcore/8.2.0 9) libreadline/8.0-GCCcore-8.2.0 13) GMP/6.1.2-GCCcore-8.2.0 2) DefaultModules 6) bzip2/1.0.6-GCCcore-8.2.0 10) Tcl/8.6.9-GCCcore-8.2.0 14) libffi/3.2.1-GCCcore-8.2.0 3) gcc/8.2.0 7) zlib/1.2.11-GCCcore-8.2.0 11) SQLite/3.27.2-GCCcore-8.2.0 15) Python/3.7.2-GCCcore-8.2.0 4) slurm/19.05.1 8) ncurses/6.1-GCCcore-8.2.0 12) XZ/5.2.4-GCCcore-8.2.0
Also a note of warning: When you load several modules, it is possible that their dependencies can cause conflicts and problems later on. It is best to always check what other modules have been automatically loaded.
Unload modules
The command module unload
“un-loads” a module. For the above example:
[me@nodelogin01 ~]$ module unload Python/3.7.2-GCCcore-8.2.0 [me@nodelogin01 ~]$ module list Currently Loaded Modules: 1) shared 5) GCCcore/8.2.0 9) libreadline/8.0-GCCcore-8.2.0 13) GMP/6.1.2-GCCcore-8.2.0 2) DefaultModules 6) bzip2/1.0.6-GCCcore-8.2.0 10) Tcl/8.6.9-GCCcore-8.2.0 14) libffi/3.2.1-GCCcore-8.2.0 3) gcc/8.2.0 7) zlib/1.2.11-GCCcore-8.2.0 11) SQLite/3.27.2-GCCcore-8.2.0 4) slurm/18.08.4 8) ncurses/6.1-GCCcore-8.2.0 12) XZ/5.2.4-GCCcore-8.2.0
Important: Currently, unloading a module does not unload its dependencies (as you can see from the above output).
If you want to remove all the modules that are currently loaded, you can use the command module purge
:
[me@nodelogin01 ~]$ module purge [me@nodelogin01 ~]$ module list No modules loaded
Note that this command will also unload the modules loaded by default on login including Slurm. You can either manually load the modules back or source your bashrc with source ~/.bashrc
.