中文
注册

设置环境变量(modules方式)

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

前提条件

已安装tcl和module工具。安装命令如下所示:

  • 安装tcl工具
    yum install -y tcl*
  • 安装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.6.30/hmpi/bisheng/hmpi”,如果需要切换为GCC编译器,则需要先卸载环境变量模块“bisheng/hmpi/hmpi”,然后加载环境变量模块“gcc/hmpi/hmpi”,加载完成后,“OPAL_PREFIX”的值为“/opt/HPCKit/24.6.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.6.30/modulefiles ------------------------------------------------
    bisheng/compiler/bishengmodule      bisheng/kml/kml             gcc/compiler/gccmodule          gcc/kml/kml             hio/hio
    bisheng/hmpi/hmpi                   bisheng/kml/kspblas/omp     gcc/hmpi/hmpi                   gcc/kml/kspblas/omp
    bisheng/kml/kblas/omp               bisheng/kml/kspblas/serial  gcc/kml/kblas/omp               gcc/kml/kspblas/serial
    bisheng/kml/kblas/pthread           bisheng/kml/kvml/omp        gcc/kml/kblas/pthread           gcc/kml/kvml/omp
    bisheng/kml/kblas/serial-locking    bisheng/kml/kvml/serial     gcc/kml/kblas/serial-locking    gcc/kml/kvml/serial
    bisheng/kml/kblas/serial-nolocking  bisheng/kpccl/kpccl         gcc/kml/kblas/serial-nolocking  gcc/kpccl/kpccl

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

    module unuse /opt/HPCKit/24.6.30/modulefiles

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

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

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

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

      module load bisheng/hmpi/hmpi

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

      module unload bisheng/hmpi/hmpi

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

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

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

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

    组件名称

    模块名称

    操作步骤

    Compiler

    bisheng/compiler/bishengmodule

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

    说明:

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

    • LD_LIBRARY_PATH:动态链接库的搜索路径,例如“/opt/HPCKit/24.6.30/compiler/bisheng/lib”。
    • PATH:可执行程序的搜索路径,例如“/opt/HPCKit/24.6.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.6.30/compiler/bisheng/lib:/usr/local/lib
    /opt/HPCKit/24.6.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/compiler/gccmodule

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

    说明:

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

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

    回显信息示例:

    /opt/HPCKit/24.6.30/compiler/gcc/lib64:/usr/local/lib
    /opt/HPCKit/24.6.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/hmpi/hmpi

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

    说明:

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

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

    回显信息示例:

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

    gcc/hmpi/hmpi

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

    说明:

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

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

    回显信息示例:

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

    KML

    bisheng/kml/kml

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.6.30/kml/bisheng/lib
    /opt/HPCKit/24.6.30/kml/bisheng/include
    /opt/HPCKit/24.6.30/kml/bisheng/include
    

    bisheng/kml/kblas/serial-locking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kblas/serial-nolocking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kblas/pthread

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kspblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kspblas/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kvml/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    bisheng/kml/kvml/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kml

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

    1
    2
    3
    /opt/HPCKit/24.6.30/kml/gcc/lib
    /opt/HPCKit/24.6.30/kml/gcc/include
    /opt/HPCKit/24.6.30/kml/gcc/include
    

    gcc/kml/kblas/serial-locking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kblas/serial-nolocking

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kblas/pthread

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kspblas/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kspblas/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kvml/omp

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kml/kvml/serial

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    KPCCL

    bisheng/kpccl/kpccl

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    gcc/kpccl/kpccl

    echo $LD_LIBRARY_PATH; echo $CPATH; echo $INCLUDE

    回显信息示例:

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

    HIO

    hio/hio

    echo $HIO_HOME

    回显信息示例:

    1
    /opt/HPCKit/24.6.30/hio
    

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

    • 是,操作结束。
    • 否,请先执行4.1加载缺失环境变量模块,然后执行步骤5
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词