Editing
Environment Modules
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[Category:Babel]] [[Category:Clusters]] [[Category:LTI]] == How to Use Environment Modules in Linux == === Overview === Environment modules in Linux provide a convenient way to manage software environments by dynamically modifying the user's environment to make different software packages and versions available. This guide outlines the basic steps for using environment modules effectively. === Checking Available Modules === To view the available modules on your system, use the following command: <pre> module avail </pre> === Loading a Module === To load a specific module into your environment, use the following syntax: <pre> module load <module_name> </pre> For example, to load the CUDA module: <pre> module load cuda-12.3 </pre> === Verifying Loaded Modules === To confirm that a module has been successfully loaded, use the following command: <pre> module list </pre> This will display a list of all currently loaded modules. === Using Software with Loaded Modules === Once a module is loaded, you can use the associated software as usual. For example, if you've loaded the CUDA module, you can compile CUDA programs or run CUDA-enabled applications. === Unloading Modules === If a module is no longer needed, you can unload it using the following syntax: <pre> module unload <module_name> </pre> For example, to unload the CUDA module: <pre> module unload cuda-12.3 </pre> === Permanent Configuration === To automate the loading of frequently used modules, you can add the relevant `module load` commands to your shell configuration file (e.g., .bashrc). === Example === <pre> module load cuda-12.3 </pre> This loads the CUDA module version 12.3 into the environment. === Writing Module Files === You can create custom module files to define your own environment modules, which can then be loaded using the <code>module load</code> command. Follow these steps to create a module file: 1. '''Modules Directory:''' Create the following dir <code>$HOME/privatemodules</code> 2. '''Create the Module File:''' Use a text editor to create a file with a descriptive name. For example, to create a module ''cuda version 12.3'', create a file named <code>cuda-12.3</code>. 3. '''Define the Module''': Here's an example for a CUDA 12.3 module: <pre> #%Module ## ## cuda modulefile ## ## modulefiles/ ## set ver 12.3 set msg "This module adds CUDA $ver to various paths\n" proc ModulesHelp { } { puts stderr $msg } module-whatis "Use CUDA tools $ver" setenv CUDA_PATH /usr/local/$ver prepend-path PATH /usr/local/cuda-${ver}/bin prepend-path LD_LIBRARY_PATH /usr/local/cuda-${ver}/lib64 </pre> Adjust the paths and version numbers according to your specific setup. The <code>ModulesHelp</code> procedure provides a description of the module's purpose, which can be viewed using <code>module help <module_name></code>. 4. '''Load your Module''': Use <code>module load use.own</code> to load modules from your `$HOME/privatemodules` directory. 5. '''View your Modules''': Use <code>module avail</code> to load modules from your `$HOME/privatemodules` directory. <pre> (base) [dvosler@babel-4-7 ~]$ nvcc -V -bash: nvcc: command not found (base) [dvosler@babel-4-7 ~]$ module avail --------------------------------- /usr/share/Modules/modulefiles --------------------------------- cuda-11.6 cuda-11.7 cuda-11.8 cuda-12.0 cuda-12.1 cuda-12.2 cuda-12.3 dot gcc-7.4 module-git module-info modules null use.own zsh-5.9 ------------------------------------- /usr/share/modulefiles ------------------------------------- mpi/mpich-x86_64 pmi/pmix-x86_64 (base) [dvosler@babel-4-7 ~]$ module load use.own (base) [dvosler@babel-4-7 ~]$ module avail --------------------------- /usr/share/Modules/modulefiles ----------------------- cuda-11.6 cuda-11.7 cuda-11.8 cuda-12.0 cuda-12.1 cuda-12.2 cuda-12.3 dot gcc-7.4 module-git module-info modules null use.own zsh-5.9 --------------------------- /usr/share/modulefiles ------------------------------- mpi/mpich-x86_64 pmi/pmix-x86_64 --------------------------- $HOME/privatemodules --------------------------------- e-acc-99 </pre> 6. '''Verify the Module:''' After loading the module, use `module list` to verify that it has been successfully loaded. You should see your custom module listed among the loaded modules. 7. '''Testing:''' Test your module to ensure that it sets up the environment correctly and provides access to the desired software. === Conclusion === By following these steps, you can effectively manage software environments using environment modules in Linux. This guide provides a comprehensive overview of using environment modules in Linux, suitable for both beginners and advanced users.
Summary:
Please note that all contributions to CMU -- Language Technologies Institute -- HPC Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Tools
What links here
Related changes
Page information