Modulefiles

Modulefiles#

The Modules package is a tool that simplifies shell initialization and lets users easily modify their environment during a session using modulefiles.

Installing Modules on Unix#

sudo apt install tcl8.6-dev # 8.5 >= version
./configure --prefix=/usr/share/Modules \
            --modulefilesdir=/etc/modulefiles
make
make install
ln -s PREFIX/init/profile.sh /etc/profile.d/modules.sh
ln -s PREFIX/init/profile.csh /etc/profile.d/modules.csh

Example of modulefiles#

Anaconda3 python

#%Module1.0#####################################################################
##
## modules modulefile
##
proc ModulesHelp { } {
        global version prefix

        puts stderr "\tmodules - loads the modules software & application environment"
        puts stderr "\n\tThis adds $prefix/* to several of the"
        puts stderr "\tenvironment variables."
        puts stderr "\n\tVersion $version\n"
}

module-whatis   "loads the modules environment"

# for Tcl script use only
set     version         2020.09.1
set     prefix          /home/$USER/anaconda3/envs/some_venv

prepend-path    PATH                $prefix/bin
prepend-path    LD_LIBRARY_PATH     $prefix/lib
# prepend-path    MANPATH               /usr/local/Modules/share/man

# enable module versioning modulepath
# module use /usr/local/Modules/versions

CUDA

#%Module1.0#####################################################################
##
## modules modulefile
##
proc ModulesHelp { } {
        global version prefix

        puts stderr "\tmodules - loads the modules software & application environment"
        puts stderr "\n\tThis adds $prefix/* to several of the"
        puts stderr "\tenvironment variables."
        puts stderr "\n\tVersion $version\n"
}

module-whatis   "loads the modules environment"

# for Tcl script use only
set     version         10.2.89
set     prefix          /usr/local/cuda-10.2


# setenv          MODULESHOME   $prefix
setenv          CUDA_HOME       $prefix

prepend-path    LD_LIBRARY_PATH $prefix/lib64
prepend-path    PATH            $prefix/bin
# prepend-path    MANPATH               /usr/local/Modules/share/man

# enable module versioning modulepath
#module use /usr/local/Modules/versions