Skip to content

Using Modules

Some programs may have multiple versions on the HPC or require some setup prior to using them such as setting the PATH environment variable. The module package simplifies this for users.

For the full manual on the module package type man module.

List available Modules

Here we list the available modules:

$ module avail
----------------- /etc/modulefiles ----------------- 
cuda-11.3  cuda-11.4  cuda-11.5  cuda-11.8  cuda-12.1  cuda-latest  
java-1.8.0 java-17 java-20 matlab-2017b  openmpi-4.1.5

Depending on what groups your in there may be many more modules listed. For instance, if your in the C3 group you can add the line below to your .bash_profile file. You will need to logout and log back in again for the .bash_profile to be reloaded.

export MODULEPATH=/shared/c3/apps/modules:$MODULEPATH

If your in the Remote Sensing Group you can add this line:

export MODULEPATH=/shared/rsg/apps/modules/:$MODULEPATH

If the command module avail shows more than a screenful then press the space bar to continue.

Loading and Unloading Modules

If we wish to use CUDA 11.8 (i.e. specifically version 11.8) we would load that module. Below we can see how loading the module prepends the path to that CUDA version to our existing path:

$ echo $PATH

$ module load cuda-11.8

$ echo $PATH

Now unload the module to return to our default environment:

$ module unload cuda-11.8
$ echo $PATH

You will also notice there is a cuda-latest module. That will always load the latest CUDA version, in this case cuda-12.1.

You can load multiple modules. A module will not load if there is an incompatability.

Other Module Commands

List the currrently loaded modules:

$ module list

Display information about a module:

$ module display modulefile  (e.g. module display cuda-12.1)

Color Output

If you want colored output from the module command you can add the --color option to the module command or set export MODULES_COLOR="always" in your .bash_profile file.

$ module display cuda-12.1 --color

What’s in a Module File?

You can have a look at what a module does as its a plain text file.

$ cat /etc/modulefiles/cuda-12.1
#%Module    1.0
# CUDA 11.8 module 

prepend-path    PATH            /usr/local/cuda-12.1/bin
prepend-path    MANPATH         /usr/local/cuda-12.1/doc/man
prepend-path    LD_LIBRARY_PATH /usr/local/cuda-12.1/lib64


Environment Modules