Module framework

From HP-SEE Wiki

Jump to: navigation, search

Contents

What are Environment Modules?

The Environment Modules package provides for the dynamic modification of a user's environment via modulefiles.

Each modulefile contains the information needed to configure the shell for an application. Once the Modules package is initialized, the environment can be modified on a per-module basis using the module command which interprets modulefiles. Typically modulefiles instruct the module command to alter or set shell environment variables such as PATH, MANPATH, etc. modulefiles may be shared by many users on a system and users may have their own collection to supplement or replace the shared modulefiles.

Modules can be loaded and unloaded dynamically and atomically, in an clean fashion. All popular shells are supported, including bash, ksh, zsh, sh, csh, tcsh, as well as some scripting languages such as perl.

Modules are useful in managing different versions of applications. Modules can also be bundled into metamodules that will load an entire suite of different applications.

Website: http://modules.sourceforge.net

Install Instructions

1. Install tcl and tcl-dev packages

   % yum install tcl tcl-dev

2. Download and extract Modules framework

   http://sourceforge.net/projects/modules/files/Modules/

3. Configure

   % ./configure --with-static=yes --prefix=/usr/share

4. Make and make install

   % make
   % make install

5. Make file /etc/profile.d/modules.sh with the following content:

  shell=`/bin/basename \`/bin/ps -p $$ -ocomm=\``
  if [ -f /usr/share/Modules/3.2.8/init/$shell ]
  then
    . /usr/share/Modules/3.2.8/init/$shell
  else
    . /usr/share/Modules/3.2.8/init/sh
  fi

If your path to modules init folder is different replace it.

How to add module

In this example we will add NVidia CUDA as module.

1. Make dir

  /usr/share/Modules/3.2.8/modulefiles/<name of the module>

in our case

  /usr/share/Modules/3.2.8/modulefiles/nvidia

2. Make file in this dir for the module - in our case "cuda32" with the following content:

  #%Module1.0
  #
  # This is module file for loading CUDA 3.2
  #
  #
  prepend-path PATH /usr/local/cuda32/16/cuda/bin
  prepend-path LD_LIBRARY_PATH /usr/local/cuda32/16/cuda/lib64

3. Run the command

   % module avail

and the result list must contain "nvidia/cuda32"

4. Run

  % module add nvidia/cuda32

to add it.

Quick Examples

Here is an example of loading a module on a Linux machine under bash.

   % module load gcc/3.1.1
   % which gcc

/usr/local/gcc/3.1.1/linux/bin/gcc Now we'll switch to a different version of the module

   % module switch gcc gcc/3.2.0
   % which gcc
   /usr/local/gcc/3.2.0/linux/bin/gcc

And now we'll unload the module altogether

  % module unload gcc
  % which gcc
  gcc not found

Now we'll log into a different machine, using a different shell (tcsh).

   tardis-> module load gcc/3.1.1
   tardis-> which gcc
   /usr/local/gcc/3.1.1/sunos5.6/bin/gcc

Note that the command line is exactly the same, but the path has automatically configured to the correct architecture.

Documentation