Here’s how I did it.
yum install environment-modules -y
On my CentOS 7, this is what I get when I check the package information:
root@beta ~ ## > rpm -qi environment-modules Name : environment-modules Version : 3.2.10 Release : 10.el7 Architecture: x86_64 Install Date: Wed 28 Sep 2016 05:08:40 PM CEST Group : System Environment/Base Size : 220124 License : GPLv2+ Signature : RSA/SHA256, Wed 25 Nov 2015 03:27:36 PM CET, Key ID 24c6a8a7f4a80eb5 Source RPM : environment-modules-3.2.10-10.el7.src.rpm Build Date : Fri 20 Nov 2015 06:44:07 AM CET Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://modules.sourceforge.net/ Summary : Provides dynamic modification of a user's environment Description : 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. NOTE: You will need to get a new shell after installing this package to have access to the module alias.
I made a first module as described on the Admin Magazine. Our gcc version is 4.8.5, so I customize the module file for this one. In my case we “cd” to the default module folders, make a specific folder for the specific type of program, and copy the template
root@beta ## > cd /usr/share/Modules/modulefiles root@beta ## > mkdir compilers root@beta ## > cp modules compilers/gcc-4.8.5
Then we edit the module info (compilers/gcc-4.8.5). The modified version looks like this:
#%Module1.0################################### ## ## modules compilers/gcc-4.8.5 ## ## modulefiles/compilers/gcc-4.8.5. Sample gcc module ## proc ModulesHelp { } { global version modroot puts stderr "compilers/gcc-4.8.5 - sets the Environment for GCC 4.8.5 " } module-whatis "Sets the environment for using gcc-4.8.5 (C, Fortran)" # for Tcl script use only set topdir /usr/bin/gcc set version 4.8.5 set sys linux86 setenv CC $topdir/bin/gcc setenv GCC $topdir/bin/gcc setenv FC $topdir/bin/gfortran setenv F77 $topdir/bin/gfortran setenv F90 $topdir/bin/gfortran prepend-path PATH $topdir/include prepend-path PATH $topdir/bin prepend-path MANPATH $topdir/man prepend-path LD_LIBRARY_PATH $topdir/lib
Will that be enough? To test it, I log in as a user on the machine and try to load the module:
yo@beta ~ $ > module avail ------------------/usr/share/Modules/modulefiles -------------- compilers/gcc-4.8.5 dot module-git module-info modules null use.own yo@beta ~ $ > module help compilers/gcc-4.8.5 ----------- Module Specific Help for 'compilers/gcc-4.8.5' -------- compilers/gcc-4.8.5 - sets the Environment for GCC 4.8.5 yo@beta ~ $ > module whatis compilers/gcc-4.8.5 compilers/gcc-4.8.5 : Sets the environment for using gcc-4.8.5 (C, Fortran) yo@beta ~ $ > module load compilers/gcc-4.8.5 yo@beta ~ $ > module list Currently Loaded Modulefiles: 1) compilers/gcc-4.8.5
So yes, it’s enough. I start creating happily modules and I find out that the most crucial part (as expected) seems to be where is the software compiled, the architecture, and the libraries needed.
If you don’t have clear still what to do with modules or how to handle them, you can check the Confluence page (pay attention to the table of commands on Basic Module Usage) the the FAQ of Sourceforge, the Linux Software Modules page of Illinois University, The Viriginia Tech page or the Michigan University page. Even Wikipedia has a link about it. Or you can google it yourself 🙂
To install it in our SLURM cluster, since we had previously a collection of programs in /usr/local, we only need to rsync the corresponding folder
rsync -av /usr/share/Modules/modulefiles/ $i:/usr/share/Modules/modulefiles/
After that, unfortunately, if you lauch a job that calls module load SLURM gives this error
/var/spool/slurmd/job00682/slurm_script: /usr/bin/modulecmd: No such file or directory
But the error has a very easy workaround as found on the confluence wiki
from
#!/bin/bash
to
#!/bin/bash -login
The error, as explained, is due to the use of the bash shell, instead of the SLURM shell.
Pingback: Add module path on CentOS 7 | Bits and Dragons