Environment Modules

Environment Modules

Environment modules are used to manage multiple versions of software on a single system. For example, you may wish to compile a particular code with version 4.2.1 of gcc while a different piece of code requires gcc version 4.4.2. With modules you can keep both compiler versions on the system and move between the two easily. At its core, the module software makes dynamic temporary alterations to pertinent environment variables (PATH, LD_LIBRARY_PATH, LIBRARY_PATH, etc.). Kamiak uses the Lmod module system from TACC.

Available Modules

To see a list of all the modules available on the cluster run the module avail command

-bash-4.2$ module avail
------------------------------------------- /opt/apps/modulefiles/Core -------------------------------------------
   anaconda2/2.4.0                git/2.6.3                petsc/3.6.3_mvapich2-2.2b         settarg/6.0.1
   anaconda3/2.4.0                lmod/6.0.1               petsc/3.6.3_openmpi-1.10.1 (D)    svn/2.7.10
   blas/3.6.0                     mpich/3.2                python/2.7.10                     valgrind/3.11.0
   boost/1.59.0_openmpi-1.10.1    mvapich2/2.2b            python3/3.4.3
   gcc/5.2.0                      openmpi/1.10.1           python3/3.5.0              (D)
   gdb/7.10.1                     petsc/3.6.3_mpich-3.2    r/3.2.2
  Where:
   (D):  Default Module
Use "module spider" to find all possible modules.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
-bash-4.2$ 

Loading and Unloading Modules

First, let’s see what version of gcc is currently invoked by the gcc command

-bash-4.2$ gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-bash-4.2$ 

Now load a different version of gcc by using the command module load followed by the name of the desired module

-bash-4.2$ 
-bash-4.2$ module load gcc/5.2.0 
-bash-4.2$ gcc --version
gcc (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-bash-4.2$ which gcc
/opt/apps/gcc/5.2.0/bin/gcc
-bash-4.2$ 

To return to the base version gcc we run the command module unload followed by the name of the loaded module

-bash-4.2$ 
-bash-4.2$ module unload gcc/5.2.0 
-bash-4.2$ gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-bash-4.2$ which gcc
/usr/bin/gcc
-bash-4.2$ 

Listing Loaded Modules

To find out which modules are currently loaded run the command module list

-bash-4.2$ module list
Currently Loaded Modules:
  1) gcc/5.2.0
-bash-4.2$