Environment Modules

Environment Modules allow for management of environment variables  when using multiple compilers, multiple libraries, or even versions of applications that you might need to run. Rather than change $PATH, $LD_LIBRARY_LOAD, or $MANPATH for each you can use Environment Modules to handle the path changes to ensure you run the appropriate version correctly.

Installation

On CentOS etc:

On Ubuntu/Debian-esque:

Usage

Important: Log out and log back in again

Then check the modules that are currently available:

Selection_071 Adding a Module

I’d like to add a module to set an alternative GCC compiler. The system version of GCC was at /usr/bin/gcc and was version 4.4.7. A more updated version 4.9.0 was comiled under /var/shared/gcc-4.9.0

To add an Environment Module for my custom GCC version 4.9.0, I did the following:

The modules file copied above is a useful template but I amended a file by Jeff Layton from admin-magazine.com :

To activate this environment:

Selection_072

Now if I run module list I can see the new module has been added:

If I run:

I should see:

This assumes that there is a binary named gcc in /var/shared/gcc-4.9.0/bin – if there is not create a symbolic link to it. For example, I needed to do:

Unloading Modules

To unload a module and return to using the system provided paths:

This should show no modules and running ‘which gcc’ should show the system gcc again:

Selection_073

I can now distribute the /usr/share/Modules/modulefiles/compilers/gcc-4.9.0 file among the cluster via Puppet for use on any cluster node.

 

 

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">