Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

EnvironmentModules.txt 4.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  1. = Environment Modules
  2. == Introduction
  3. When one has multiple programs serving the same purpose (for instance SMTP servers such as sendmail, exim and postfix; or print servers such as lprng and cups), it is usual to wrap these using alternatives. Alternatives provides a clean way to have many types of software serving the same purpose installed at the same time and have the commands such as `+mail+` and `+lpr+` point to the wanted versions.
  4. However, when there are multiple variants that each serve the needs of some user and thus must be available simultaneously by users, the alternatives system simply isn't enough since it is system-wide. This has been reality on supercomputers and clusters for eons, and multiple implementations of a solution has been developed: http://modules.sourceforge.net/[environment modules] and https://www.tacc.utexas.edu/tacc-projects/lmod[Lmod]. Fedora currently makes use of this primarily for handling switching between different MPI implementations.
  5. Environment modules are also useful in situations where a package wants to install binaries that use common names and might conflict file in or otherwise pollute /usr/bin. Use must then load an environment module before being able to make use of those programs.
  6. == Using environment modules
  7. To see what modules are available, run `+$ module avail+`.
  8. To load a module run e.g. `+$ module load mpi/openmpi-x86_64+`.
  9. To unload a module, run e.g. `+$module unload mpi/openmpi-x86_64+`.
  10. The upstream documentation for the module command is available https://modules.readthedocs.io/en/stable/module.html[here] or with `+man module+`.
  11. == Creating environment modules
  12. To install an environment module, place a module file into `+%{_modulesdir}+`, which should evaluate to `+/usr/share/modulefiles+`. This macro is available in Fedora and EPEL 7+. The directory `+/usr/share/Modules/modulefiles+` is to be used only for internal modules of environment-modules. `+/etc/modulefiles+` is available to local system administrator use.
  13. The module files are plain text with optional tcl syntax, for instance an environment module for 64-bit OpenMPI `+mpi/openmpi-x86_64+`:
  14. ....
  15. #%Module 1.0
  16. #
  17. # OpenMPI module for use with 'environment-modules' package:
  18. #
  19. conflict mpi
  20. prepend-path PATH /usr/lib64/openmpi/bin
  21. prepend-path LD_LIBRARY_PATH /usr/lib64/openmpi/lib
  22. prepend-path PYTHONPATH /usr/lib64/python2.7/site-packages/openmpi
  23. prepend-path MANPATH /usr/share/man/openmpi-x86_64
  24. setenv MPI_BIN /usr/lib64/openmpi/bin
  25. setenv MPI_SYSCONFIG /etc/openmpi-x86_64
  26. setenv MPI_FORTRAN_MOD_DIR /usr/lib64/gfortran/modules/openmpi-x86_64
  27. setenv MPI_INCLUDE /usr/include/openmpi-x86_64
  28. setenv MPI_LIB /usr/lib64/openmpi/lib
  29. setenv MPI_MAN /usr/share/man/openmpi-x86_64
  30. setenv MPI_PYTHON_SITEARCH /usr/lib64/python2.7/site-packages/openmpi
  31. setenv MPI_COMPILER openmpi-x86_64
  32. setenv MPI_SUFFIX _openmpi
  33. setenv MPI_HOME /usr/lib64/openmpi
  34. ....
  35. The module file begins with the magic cookie `+#%Module +`, where is the version of the module file used. The current version is 1.0.
  36. The above commands prepends the path with the bindir of the 64-bit OpenMPI (compiled with GCC) and adds the relevant library path. Then it sets various environment variables.
  37. It is also possible to set `+CFLAGS+` and `+LDFLAGS+` with the above manner, but in the case of MPI compilers it is not necessary since the compilers are invoked with the `+mpicc+`, `+mpicxx+`, `+mpif77+` and `+mpif90+` wrappers that already contain the necessary include and library paths. Also, in the case of development packages an override of `+CFLAGS+` and/or `+LDFLAGS+` is not sane, as it may cause trouble in building RPMs as it overrides `+%{optflags}+`.
  38. The upstream documentation for module files is available https://modules.readthedocs.io/en/stable/modulefile.html[here] or with `+man modulefile+`.
  39. == Switching between module implementations
  40. Switching between the environment-modules and Lmod implementations is done via alternatives. The shell init scripts /etc/profile.d/modules.\{csh,sh} are links to /etc/alternatives/modules.\{csh.sh} and can be manipulated with the alternatives command.
  41. == Lmod
  42. https://www.tacc.utexas.edu/tacc-projects/lmod[Lmod] is an environment modules implementation written in Lua, and can make use of module files written in Lua as well as Tcl. Such files have a ".lua" extensions. However, such files *must not* be installed /usr/share/modulefiles so as to not cause issues when the environment-modules package is in use. Instead install into %\{_datadir}/lmod/lmod/modulefiles/Core.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...