中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
鲲鹏小智

设置环境变量(modules方式)

modules方式支持选择加载环境变量管理模块,本文介绍使用modules方式加载环境变量管理模块的方法。

前提条件

  • 已配置yum源。执行以下命令检查节点YUM源是否已配置,确保回显中有OS对应的YUM源。

    yum list | grep kernel

  • 已安装tcl工具。
    执行以下命令检查是否已安装tcl工具。
    yum list installed | grep tcl.aarch64

    回显有如下信息说明已安装tcl工具。

    tcl.aarch64                                        1:8.6.12-4.oe2203sp1             @anaconda
    如果未安装tcl工具,执行以下命令安装。
    yum install -y tcl*
  • 已安装module工具。
    执行以下命令检查是否已安装module工具。
    yum list installed | grep environment-modules.aarch64
    回显有如下信息说明已安装module工具。
    environment-modules.aarch64                        5.0.1-3.oe2203sp1                @OS
    如果未安装module工具,执行以下命令安装,并加载环境变量。
    yum install -y environment-modules
    source /etc/profile.d/modules.sh

注意事项

建议同一环境中使用一种编译器进行编译,如果同时使用两种编译器进行编译,则需要注意环境变量信息是否正确。具体原因及配置方法如下:

由于环境变量信息中,参数“CC”、“CXX”、“FC”、“F77”、“F90”和“OPAL_PREFIX”的值只针对当前使用的编译器生效,如果要使用另一种编译器,需要先卸载当前已有环境变量模块,然后加载需要另一种编译器进行编译的组件环境变量模块。不同编译器编译对应组件的环境变量管理模块时,其环境变量参数值请参见表1

示例:

当前使用毕昇编译器,已加载环境变量模块“bisheng/hmpi/hmpi”,此时,“OPAL_PREFIX”的值为“/opt/HPCKit/24.12.30/hmpi/bisheng/hmpi”,如果需要切换为GCC编译器,则需要先卸载环境变量模块“bisheng/hmpi/hmpi”,然后加载环境变量模块“gcc/hmpi/hmpi”,加载完成后,“OPAL_PREFIX”的值为“/opt/HPCKit/24.12.30/hmpi/gcc/hmpi”。

操作步骤

  1. 使用PuTTY工具,登录HPCKit的安装节点。
  2. 执行以下命令,进入HPCKit安装目录。
    cd /opt/HPCKit/latest

    /opt:HPCKit的默认安装目录,请替换为实际路径。

  3. 执行以下命令,添加modulefiles。
    module use modulefiles

    使用 sh modulefiles-setup.sh 可以恢复误删的 modulefiles 文件夹。

  4. 执行以下命令,查询可用环境变量模块。
    module avail

    回显如下类似信息:

    -------------------------------------------------------------------------------------------------------------------- /opt/HPCKit/24.12.30/modulefiles ---------------------------------------------------------------------------------------------------------------------
    bisheng/compiler4.1.0/bishengmodule  bisheng/kml2.5.0/kblas/serial-locking    bisheng/kml2.5.0/kspblas/serial  gcc/compiler12.3.1/gccmodule  gcc/kml2.5.0/kblas/serial-locking    gcc/kml2.5.0/kspblas/serial  hio2.4.2/hio
    bisheng/hmpi2.4.3/hmpi               bisheng/kml2.5.0/kblas/serial-nolocking  bisheng/kml2.5.0/kvml/omp        gcc/hmpi2.4.3/hmpi            gcc/kml2.5.0/kblas/serial-nolocking  gcc/kml2.5.0/kvml/omp
    bisheng/kml2.5.0/kblas/omp           bisheng/kml2.5.0/kml                     bisheng/kml2.5.0/kvml/serial     gcc/kml2.5.0/kblas/omp        gcc/kml2.5.0/kml                     gcc/kml2.5.0/kvml/serial
    bisheng/kml2.5.0/kblas/pthread       bisheng/kml2.5.0/kspblas/omp             bisheng/kpccl24.0.0/kpccl        gcc/kml2.5.0/kblas/pthread    gcc/kml2.5.0/kspblas/omp             gcc/kpccl24.0.0/kpccl
    

    如果回显信息中包含不需要加载的模块信息,您可以执行以下命令删除。

    module unuse /opt/HPCKit/24.12.30/modulefiles

    其中,”/opt/HPCKit/24.12.30/modulefiles”为模块名称,请根据实际情况替换。

  5. 加载环境变量模块。
    1. 执行以下命令,将组件的相关信息添加至环境变量中。
      module load modulefile

      modulefile:组件环境变量管理模块,具体请参见组件环境变量管理模块信息

      示例:将HMPI组件bisheng版本信息添加到环境变量中

      module load bisheng/hmpi2.4.3/hmpi

      当存在环境变量模块不再使用时,您可以执行以下命令卸载。

      module unload bisheng/hmpi2.4.3/hmpi

      其中,”bisheng/hmpi2.4.3/hmpi”为待删除的环境变量模块,请根据实际情况替换。

    2. 执行以下命令,查看已加载环境变量模块。
      module list

      在回显信息中查看所需环境变量模块是否均存在。

      • 是,请执行步骤6
      • 否,请先执行5.a加载缺失环境变量模块,然后执行6
  6. 查询对应组件的环境变量信息。
    表1 组件环境变量信息的查询方法

    组件名称

    模块名称

    操作步骤

    Compiler

    bisheng/compiler4.1.0/bishengmodule

    echo $LD_LIBRARY_PATH; echo $PATH; echo $CC; echo $CXX; echo $FC; echo $F77; echo $F90

    说明:

    环境变量参数含义具体如下:

    • LD_LIBRARY_PATH:动态链接库的搜索路径,例如“/opt/HPCKit/24.12.30/compiler/bisheng/lib”。
    • PATH:可执行程序的搜索路径,例如“/opt/HPCKit/24.12.30/compiler/bisheng/bin”。
    • CC:编译C语言程序的编译器名称,值为clang。
    • CXX:编译C++程序的编译器名称,值为clang++。
    • FC:编译Fortran程序的编译器名称,值为flang。
    • F77:编译Fortran77程序的编译器名称,值为flang。
    • F90:编译Fortran90程序的编译器名称,值为flang。

    回显信息示例:

    1
    2
    3
    4
    5
    6
    7
    /opt/HPCKit/24.12.30/compiler/bisheng/lib:/usr/local/lib
    /opt/HPCKit/24.12.30/compiler/bisheng/bin:/usr/local/shc/bin:/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    clang
    clang++
    flang
    flang
    flang
    

    gcc/compiler12.3.1/gccmodule

    echo $LD_LIBRARY_PATH; echo $PATH; echo $CC; echo $CXX; echo $FC; echo $F77; echo $F90

    说明:

    环境变量参数含义具体如下:

    • LD_LIBRARY_PATH:动态链接库的搜索路径,例如“/opt/HPCKit/24.12.30/compiler/gcc/lib64:/opt/HPCKit/24.12.30/compiler/gcc/lib”。
    • PATH:可执行程序的搜索路径,例如“/opt/HPCKit/24.12.30/compiler/gcc/bin”。
    • CC:编译C语言程序的编译器名称,值为gcc。
    • CXX:编译C++程序的编译器名称,值为g++。
    • FC:编译Fortran程序的编译器名称,值为gfortran。
    • F77:编译Fortran77程序的编译器名称,值为gfortran。
    • F90:编译Fortran90程序的编译器名称,值为gfortran。

    回显信息示例:

    /opt/HPCKit/24.12.30/compiler/gcc/lib64:/usr/local/lib
    /opt/HPCKit/24.12.30/compiler/gcc/bin:/usr/local/shc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    gcc
    g++
    gfortran
    gfortran
    gfortran

    HMPI

    bisheng/hmpi2.4.3/hmpi

    echo $LD_LIBRARY_PATH; echo $PATH; echo $INCLUDE; echo $OPAL_PREFIX

    说明:

    环境变量参数含义具体如下:

    • LD_LIBRARY_PATH:动态链接库的搜索路径,例如“/opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/lib:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/lib:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/lib”。
    • PATH:可执行程序的搜索路径,例如“/opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/bin:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/bin:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/bin”。
    • INCLUDE:Hyper MPI中hmpihucxxucg组件的头文件目录,例如“/opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/include:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/include:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/include”。
    • OPAL_PREFIX:Hyper MPI中hmpi组件的安装目录,例如“/opt/HPCKit/24.12.30/hmpi/bisheng/hmpi”。

    回显信息示例:

    1
    2
    3
    4
    /opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/lib:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/lib:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/lib:/usr/local/lib
    /opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/bin:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/bin:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    /opt/HPCKit/24.12.30/hmpi/bisheng/hmpi/include:/opt/HPCKit/24.12.30/hmpi/bisheng/hucx/include:/opt/HPCKit/24.12.30/hmpi/bisheng/xucg/include
    /opt/HPCKit/24.12.30/hmpi/bisheng/hmpi
    

    gcc/hmpi2.4.3/hmpi

    echo $LD_LIBRARY_PATH; echo $PATH; echo $INCLUDE; echo $OPAL_PREFIX

    说明:

    环境变量参数含义具体如下:

    • LD_LIBRARY_PATH:动态链接库的搜索路径,例如“/opt/HPCKit/24.12.30/hmpi/gcc/hmpi/lib:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/lib:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/lib”。
    • PATH:可执行程序的搜索路径,例如“/opt/HPCKit/24.12.30/hmpi/gcc/hmpi/bin:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/bin:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/bin”。
    • INCLUDE:Hyper MPI中hmpi、hucx和xucg组件的头文件目录,例如“/opt/HPCKit/24.12.30/hmpi/gcc/hmpi/include:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/include:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/include”。
    • OPAL_PREFIX:Hyper MPI中hmpi组件的安装目录,例如“/opt/HPCKit/24.12.30/hmpi/gcc/hmpi”。

    回显信息示例:

    /opt/HPCKit/24.12.30/hmpi/gcc/hmpi/lib:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/lib:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/lib:/usr/local/lib
    /opt/HPCKit/24.12.30/hmpi/gcc/hmpi/bin:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/bin:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    /opt/HPCKit/24.12.30/hmpi/gcc/hmpi/include:/opt/HPCKit/24.12.30/hmpi/gcc/hucx/include:/opt/HPCKit/24.12.30/hmpi/gcc/xucg/include
    /opt/HPCKit/24.12.30/hmpi/gcc/hmpi

    KML

    bisheng/kml2.5.0/kml

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE;

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib:/opt/HPCKit/24.12.30/kml/bisheng/lib/noarch:/opt/HPCKit/24.12.30/kml/bisheng/lib/neon
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kblas/serial-locking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib/neon/kblas/locking
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kblas/serial-nolocking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/neon/lib/kblas/nolocking
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/neon/lib/kblas/omp
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kblas/pthread

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/neon/lib/kblas/pthread
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kspblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib/neon/kspblas/multi
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kspblas/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib/neon/kspblas/single
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kvml/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib/noarch/kvml/multi
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    bisheng/kml2.5.0/kvml/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/bisheng/lib/noarch/kvml/single
    /opt/HPCKit/24.12.30/kml/bisheng/include
    /opt/HPCKit/24.12.30/kml/bisheng/include
    

    gcc/kml2.5.0/kml

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib:/opt/HPCKit/24.12.30/kml/gcc/lib/noarch:/opt/HPCKit/24.12.30/kml/gcc/lib/neon
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kblas/serial-locking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kblas/locking
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kblas/serial-nolocking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kblas/nolocking
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kblas/omp
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kblas/pthread

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kblas/pthread
    /opt/HPCKit//kml/gcc/include
    /opt/HPCKit//kml/gcc/include
    

    gcc/kml2.5.0/kspblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kspblas/multi
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kspblas/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/neon/kspblas/single
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kvml/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/noarch/kvml/multi
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    gcc/kml2.5.0/kvml/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kml/gcc/lib/noarch/kvml/single
    /opt/HPCKit/24.12.30/kml/gcc/include
    /opt/HPCKit/24.12.30/kml/gcc/include
    

    KPCCL

    bisheng/kpccl24.0.0/kpccl

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kpccl/bisheng/lib
    /opt/HPCKit/24.12.30/kpccl/bisheng/include
    /opt/HPCKit/24.12.30/kpccl/bisheng/include
    

    gcc/kpccl24.0.0/kpccl

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.12.30/kpccl/gcc/lib
    /opt/HPCKit/24.12.30/kpccl/gcc/include
    /opt/HPCKit/24.12.30/kpccl/gcc/include
    

    HIO

    hio2.4.2/hio

    echo $HIO_HOME

    回显信息示例:

    1
    /opt/HPCKit/24.12.30/hio
    

    在回显信息中,查看已加载模块的环境信息变量是否均存在。

    • 是,操作结束。
    • 否,请先执行4.1加载缺失环境变量模块,然后执行步骤5