Module Collections
Sometimes you will need to load a number of modules to perform a task. For example, while working on a genomics project, you might need to load the following modules:
gcc/13.3.0-xp3epyt samtools/1.19.2-pfmpoam
bowtie2/2.5.2-qd4omrm hisat2/2.2.1-x7h4grf
Depending on your work flow, it can be tedius to load that set of modules each time you want to do the same kind of work. Lmod provides a feature called module collections that simplifies loading a commonly used set of modules and/or switching between sets of modules. A collection is a named set of modules that can be restored with a single command; restoring a collection removes all the currently loaded modules and replaces them with those in the collection.
The list of modules loaded along with the set of modules listed above is quite long due to automatically loaded dependencies:
$ module list
Currently Loaded Modules:
1) gmp/6.2.1-ip3t4a7 (H) 19) perl/5.38.0-5qkldk7 (H)
2) mpfr/4.2.1-344sqki (H) 20) libmd/1.0.4-poltzqg (H)
3) mpc/1.3.1-dv3gprk (H) 21) libbsd/0.12.1-cgznsch (H)
4) zlib-ng/2.1.6-ibq6yfi (H) 22) expat/2.6.2-pbou4ry (H)
5) zstd/1.5.6-apl64xw (H) 23) libiconv/1.17-onkf4vg (H)
6) gcc/13.3.0-xp3epyt 24) libxml2/2.10.3-bfbmizl (H)
7) bzip2/1.0.8-pglbqco (H) 25) pigz/2.8-ak52g4i (H)
8) nghttp2/1.57.0-gg3aqta (H) 26) tar/1.34-brdiixn (H)
9) openssl/3.3.0-juxgakz (H) 27) gettext/0.22.5-nhvnthy (H)
10) curl/8.7.1-jjeqes5 (H) 28) libffi/3.4.6-gqm4k4k (H)
11) gzip/1.13-ax6bjcb (H) 29) libxcrypt/4.4.35-tu3smow (H)
12) libdeflate/1.18-vwavcwi (H) 30) sqlite/3.43.2-4rpti6s (H)
13) xz/5.4.6-43oj3jj (H) 31) util-linux-uuid/2.38.1-26fgeyx (H)
14) htslib/1.19.1-6ivqauw 32) python/3.11.7-npab4yj (H)
15) ncurses/6.5-x5amjzf (H) 33) samtools/1.19.2-pfmpoam
16) berkeley-db/18.1.40-oqy43lx (H) 34) intel-oneapi-tbb/2021.12.0-i4jasza (H)
17) readline/8.2-na6mzoq (H) 35) bowtie2/2.5.2-qd4omrm
18) gdbm/1.23-i7y4yva (H) 36) hisat2/2.2.1-x7h4grf
Where:
H: Hidden Module
You can save that list of modules to a collection called bio with
$ module save bio
We use the following steps to verify the new bio collection:
$ module purge
$ module list
No modules loaded
You can now restore the collection of modules called bio, using the
restore command, and the module list command will then return the
same list of 36 modules as shown above. We show these steps along
with the resulting list (abbreviated) below:
$ module restore bio
$ module list
Currently Loaded Modules:
1) gmp/6.2.1-ip3t4a7 (H) 19) perl/5.38.0-5qkldk7 (H)
. . .
18) gdbm/1.23-i7y4yva (H) 36) hisat2/2.2.1-x7h4grf
Where:
H: Hidden Module
You can list all of your named collections using
$ module savelist
Named collection list :
1) bio 2) geo 3) nlp
And to see what is included in any given collection, you can use
$ module describe nlp
Collection "nlp" contains:
1) gmp/6.2.1-ip3t4a7 4) zlib-ng/2.1.6-ibq6yfi 7) cuda/12.9.1
2) mpfr/4.2.1-344sqki 5) zstd/1.5.6-apl64xw 8) cudnn/9.12.0-cuda12
3) mpc/1.3.1-dv3gprk 6) gcc 9) python3.12-anaconda
Collections are stored as text files in the directory
${HOME}/.config/lmod in a file whose name is the collection name.
If you create a collection, then decide the contents should be
slightly different, simply save it again. If you modify a collection,
a backup file of the previous configuration will be saved with the ~
character appended; that is,
$ ls ~/.config/lmod/nlp*
nlp nlp~
If you decide you no longer want to have a particular collection, you should just remove the file(s), as in
$ rm ~/.config/lmod/nlp*
NOTE: Lmod recently transitioned from storing module collections
in ~/.lmod.d to using ~/.config/lmod to align with standardized
paths for saving application data. While the VACC has updated our Lmod
configuration to only store files defining module collections in the
new path, Lmod continues to check both directories for collections.
If you used module collections prior to this configuration change, you
may have collection files stored in the deprecated path
(~/.lmod.d). In this case, to completely remove a collection, you
may need to remove it from both directory paths. If you encounter
this situation, after confirming that the desired collections exist in
the new path, you can simply remove the deprecated directory to avoid
confusion:
$ ls ~/.config/lmod
bio geo nlp
$ rm -rf ~/.lmod.d
Default modules¶
You can create a default collection that will be automatically restored each time you login by saving a collection with no name given.
$ module save
Saved current collection of modules to: "default"
You can modify the collection by saving again, and you can remove it with
$ rm ~/.config/lmod/default*
If you ever change your loaded modules and wish to return to the default
collection, you restore it the same way you restore a named collection.
$ module restore default