--- title: Module 指令 | zh tags: Guide, TWNIA3, TW GA: --- {%hackmd @docsharedstyle/default %} # Module 指令 :::info #### `ml` 不同寫法使用範例說明 - 單獨執行 `ml` 時,功能等同 <b>module list</b> $ `ml` - `ml` 加上 <b>module name</b> 時,功能等同 `module load` <br> $ `ml intel/2021` ---> module load intel/2021<br> $ `ml -intel/2021` ---> module unload intel/2021<br> $ `ml intel/2021 -gcc/8.3.0` ---> 先 <b>module unload</b> gcc/8.3.0 再 <b>module load</b> intel/2021 - `ml` 搭配 <b>module</b> 指令一起使用時,功能等同 <b>module</b> ``` $ ml spider $ ml av $ ml show foo ``` :::warning <b><i class="fa fa-lightbulb-o" aria-hidden="true"></i> 說明:</b> <b>module</b> 的指令都可以在 `ml` 下搭配使用,詳細用法可參閱 <b>[原始文件](https://lmod.readthedocs.io/en/latest/010_user.html#ml-a-convenient-tool)。</b> ::: --- #### 以下常用指令執行皆以 $ `ml` 作為範例: ### module list ::: success :::spoiler <b>列出已讀取的模組設定</b> #### $ `ml` / `ml list` ``` [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 ``` ::: ### module avail ::: success ::: spoiler <b>列出所有可以被載入的module資訊</b> #### $ `ml avail` / `ml av` ``` [xxx@lgn303 ~]$ ml av ---------------------------- /pkg/modulefiles/Core ----------------------------- gcc/10.2 intel/2020_u4 Use "module spider" to find all possible modules and extensions. Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys". ``` ::: ### module spider ::: success ::: spoiler <b>搜尋所有可能的模組</b> #### $ `ml spider` ``` [xxx@lgn303 ~]$ ml spider openmpi ----------------------------------------------------------------------------------------------------------------------------------- OpenMPI: ----------------------------------------------------------------------------------------------------------------------------------- Description: Portable high-performance MPI implementation Versions: OpenMPI/4.0.3 OpenMPI/4.0.5 OpenMPI/4.1.0 ----------------------------------------------------------------------------------------------------------------------------------- For detailed information about a specific "OpenMPI" module (including how to load the modules) use the module's full name. For example: $ module spider OpenMPI/4.1.0 ----------------------------------------------------------------------------------------------------------------------------------- openmpi3: openmpi3/3.1.4 ----------------------------------------------------------------------------------------------------------------------------------- Description: A powerful implementation of MPI You will need to load all module(s) on any one of the lines below before the "openmpi3/3.1.4" module is available to load. gcc/8.3.0 Help: This module loads the openmpi3 library built with the gnu8 toolchain. Version 3.1.4 ``` ``` [xxx@lgn303 ~]$ module spider OpenMPI/4.1.0 ----------------------------------------------------------------------------------------------------------------------------------- OpenMPI: OpenMPI/4.1.0 ----------------------------------------------------------------------------------------------------------------------------------- Description: Portable high-performance MPI implementation You will need to load all module(s) on any one of the lines below before the "OpenMPI/4.1.0" module is available to load. gcc/4.8.5 intel/.2020 intel/2020u4 intel/2021 Help: This module loads the OpenMPI library (4.1.0). ``` ::: ### module show / display ::: success ::: spoiler <b>顯示模組設定內容</b> #### $ `ml show` / `ml display` ``` [xxx@lgn303 ~]$ ml show gcc/10.2 ---------------------------------------------------------------------- /pkg/modulefiles/Core/compiler/gcc/10.2.lua: ---------------------------------------------------------------------- help([[This module loads the gcc-10.2.0 compilers (10.2.0). The following additional environment variables are defined: CC (path to gcc compiler wrapper ) CXX (path to g++ compiler wrapper ) F77 (path to gfortran compiler wrapper ) F90 (path to gfortran compiler wrapper ) FC (path to gfortran compiler wrapper ) See the man pages for gcc, g++, gfortran (f77, f90). For more detailed information on available compiler options and command-line syntax.]]) whatis("Description: GCC 10.2.0 compilers") whatis("URL: www.gnu.org") prepend_path("PATH","/pkg/gcc/10.2/bin") prepend_path("PATH","/pkg/gcc/10.2/include") prepend_path("LD_LIBRARY_PATH","/pkg/gnu/isl/lib") prepend_path("LD_LIBRARY_PATH","/pkg/gcc/10.2/lib64") prepend_path("MANPATH","/pkg/gcc/10.2/man") pushenv("CC","/pkg/gcc/10.2/bin/gcc") pushenv("CXX","/pkg/gcc/10.2/bin/g++") pushenv("F77","/pkg/gcc/10.2/bin/gfortran") pushenv("FORT","/pkg/gcc/10.2/bin/gfortran") pushenv("cc","/pkg/gcc/10.2/bin/gcc") pushenv("cxx","/pkg/gcc/10.2/bin/g++") pushenv("f77","/pkg/gcc/10.2/bin/gfortran") pushenv("fort","/pkg/gcc/10.2/bin/gfortran") pushenv("FC","/pkg/gcc/10.2/bin/gfortran") pushenv("fc","/pkg/gcc/10.2/bin/gfortran") prepend_path("MODULEPATH","/pkg/modulefiles/comp/gcc/10.2") family("compiler") ``` ::: ### module load / add ::: success ::: spoiler <b>載入指定的module資訊</b> #### $ `ml load` / `ml add` ``` [xxx@lgn303 ~]$ ml load intel/2018u4 [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) intel/2018u4 ``` ::: ### module save / s ::: success ::: spoiler <b>儲存模組組合</b> #### $ `ml save` / `ml s` ``` [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 2) openmpi/4.0.5 [xxx@lgn303 ~]$ ml save gcc10-OpenMPI Saved current collection of modules to: "gcc10-OpenMPI" ``` ::: ### module restore / r ::: success ::: spoiler <b>讀取儲存的模組組合</b> #### $ `ml restore` / `ml r` ``` [xxx@lgn303 ~]$ ml No modules loaded [xxx@lgn303 ~]$ ml r gcc10-OpenMPI Restoring modules from user's gcc10-OpenMPI [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 2) openmpi/4.0.5 ``` ::: ### module savelist ::: success ::: spoiler <b>列出已儲存的模組組合</b> #### $ `ml savelist` ``` [xxx@lgn303 ~]$ ml savelist Named collection list : 1) gcc10-OpenMPI ``` ::: ### module unload / del / rm ::: success ::: spoiler <b>移除讀取的模組設定</b> #### $ `ml unload` / `ml del` / `ml rm` ``` [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 2) openmpi/4.0.5 [xxx@lgn303 ~]$ ml del openmpi/4.0.5 [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 ``` ::: ### module swap / sw / switch ::: success ::: spoiler <b>卸載m1設定並讀取m2設定</b> #### $ `ml swap` / `ml sw` / `ml switch m1 m2` ``` [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 [xxx@lgn303 ~]$ ml av -------------------- /pkg/modulefiles/comp/gcc/10.2 -------------------- openmpi/4.0.5 ------------------------ /pkg/modulefiles/Core ------------------------- gcc/10.2 (L) intel/2020_u4 Where: L: Module is loaded [xxx@lgn303 ~]$ ml sw gcc/10.2 intel/2020_u4 [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) intel/2020_u4 ``` ::: ### module purge ::: success ::: spoiler <b>清除所有讀取的模組設定</b> #### $ `ml purge` ``` [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) compiler/gcc/10.2 [xxx@lgn303 ~]$ ml av ------------------/pkg/modulefiles/comp/gcc/10.2 -------------------- openmpi/4.0.5 ------------------/pkg/modulefiles/Core ----------------------------- gcc/10.2 (L) intel/2020_u4 Where: L: Module is loaded [xxx@lgn303 ~]$ ml load openmpi/4.0.5 [xxx@lgn303 ~]$ ml Currently Loaded Modules: 1) gcc/10.2 2) openmpi/4.0.5 [xxx@lgn303 ~]$ ml purge [xxx@lgn303 ~]$ ml No modules loaded ``` ::: ### module help ::: success ::: spoiler <b>查詢模組設定說明</b> #### $ `ml whatis` / `ml help` ``` [xxx@lgn303 ~]$ ml help compiler/gcc/10.2 -------------- Module Specific Help for "compiler/gcc/10.2" ----------------- This module loads the gcc-10.2.0 compilers (10.2.0). The following additional environment variables are defined: CC (path to gcc compiler wrapper ) CXX (path to g++ compiler wrapper ) F77 (path to gfortran compiler wrapper ) F90 (path to gfortran compiler wrapper ) FC (path to gfortran compiler wrapper ) See the man pages for gcc, g++, gfortran (f77, f90). For more detailed information on available compiler options and command-line syntax. [xxx@lgn303 ~]$ module whatis gcc/10.2 gcc/10.2 : Description: GCC 10.2.0 compilers gcc/10.2 : URL: www.gnu.org ``` :::