Skip to main content

Latest Tweets

The module command

Print Friendly, PDF & Email

In February 2014, we installed the 'module' command to manage different software environments.

Using modules

If you are in an interactive shell, module is available automatically. When submitting qsub scripts, however, you need to ensure that you include the line

source /etc/profile.d/modules.sh

befor invoking the module command.

Available modules

Typing

module avail

will list available modules and software packages. For instance,

----------------------- /usr/share/Modules/modulefiles ------------------------
R/3.0.1(default)             python/2.6(default)
R/ACML/3.0.2                 python/anaconda/2.7
R/ACML/MP/3.0.2              python/anaconda/3.3
R/MKL/3.0.2                  python/anaconda/econometrics
R/MKL/MP/3.0.2               rocks-openmpi
dot                          rocks-openmpi_ib
matlab/R2012b                sas/9.2
matlab/R2013b(default)       sas/9.3(default)
module-cvs                   stata/13(default)
module-info                  stata/mp/13
modules                      stata/se/13

Loading a module

One can choose different versions of the software by simply modifying a line in the qsub program, or calling a module in an interactive qsub shell:

>module load R
>module list
Currently Loaded Modulefiles:
  1) rocks-openmpi   2) R/3.0.1
>R --version
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

Unloading modules

One can swap modules, which resets (most) of the parameters that the original load modified:

>module unload R

Specifying a specific version

Specific versions can now be specified, swapping entire environments:

>module load R/MKL/3.0.2
>R --version
R version 3.0.2 Patched (2014-01-22 r64855) -- "Frisbee Sailing"
Copyright (C) 2014 The R Foundation for Statistical Computing

A sample qsub program

Note that it is important that you specify a login shell for qsub! Otherwise, the 'module' command will not work.

#!/bin/bash -l
#PBS ncpus=4
module load R/MKL/MP/3.0.2
export OMP_NUM_THREADS=4
R --vanilla < myprog.R > myprog.$(date +%F).Rout

This will load the MKL-multi-threaded version of R, set the number of threads to be used to 4 (the same number of CPUs requested from PBS), and run the program 'myprog.R', storing results in a date-stamped log file.