跳转至

7.1 环境配置

本节介绍计算环境的 Shell 类型、home 目录配置文件,以及使用 module 工具加载软件环境的方法。

7.1.1 Shell 版本

计算环境支持 bash、tcsh、zsh

7.1.2 home 目录

File 功能 注意事项
~/.bashrc 用于用户自定义 Bash shell 的行为和环境。你可以在.bashrc文件中设置环境变量,比如修改PATH路径以添加自己的程序目录等。 当用户启动一个交互式非登录 shell 时(即打开新的终端窗口或标签),.bashrc文件会被自动加载。修改完成后需要使用source ~/.bashrc使其生效,建议每次修改前对该文件做备份,以便误操作后最大程度恢复
~/.zshrc 用于用户自定义 Zsh shell 的行为和环境,功能与.bashrc类似。 当用户启动交互式 Zsh shell 时,.zshrc文件会被自动加载。修改完成后使用source ~/.zshrc使其生效。
~/.bash_profile 登录 shell 后的配置文件,用于设置用户环境变量和启动程序。 仅在用户登录时加载

需谨慎修改的环境变量

  1. 系统路径类变量,如PATH, LD_LIBRARY_PATH等。

  2. 调度器/作业提交相关变量,Slurm 相关:SLURM_JOB_ID, SLURM_NTASKS, SLURM_SUBMIT_DIR 等。

  3. 编译器与数学库相关变量,如MKLROOT, MKL_LIBDIR, MKL_INCLUDE_DIR等。

系统关键变量不建议在~/.bashrc中修改,而是在调度器提交脚本中使用。不建议修改的系统关键变量例如:

HOME 用户主目录路径,修改后各种配置文件的路径会发生变化,导致原有配置失效SHELL 用户使用的 shell 类型,修改后可能导致原有配置失效

rc 文件中禁止包含阻塞式交互操作

如果用户的 rc 文件(.bashrc、.zshrc、.tcshrc等)中包含阻塞式输入(如read、等待用户确认等)或类似的交互式执行程序,INK 等平台在使用用户身份提交作业或创建文件时可能会失败。这是一种不规范的配置模式。

解决方案:在 rc 文件中添加非交互式会话防护,如果是非交互式会话登录,则退出 rc。代码如下:

  • BASH

    [[$-!=*i*]]&&return

  • ZSH

    if[[!-ointeractive]];thenreturnfi

  • TCSH/CSH

    if(!$?prompt)thenexitendif

7.1.3 module 工具使用说明

module工具是一种常用于高性能计算环境的动态环境管理工具。它允许用户通过加载和卸载模块文件来灵活地修改其 shell 环境,从而方便地管理软件包和依赖。主要功能包括列出可用模块、加载和卸载模块、显示当前加载的模块以及查看模块详细信息。使用module工具,用户可以轻松切换不同的软件版本,确保环境的一致性和灵活性。

添加 modulefile 路径

moduleuse/cvmfs/slurm.ihep.ac.cn/alma9/modulefiles

查找可用的软件及版本

moduleavail

输出示例:

------------------------------ /cvmfs/slurm.ihep.ac.cn/alma9/modulefiles ------------------------------------anaconda/24.3.0 intel_oneapi/compiler-rt32/2024.1.0 intel_oneapi/tbb32/2021.12cmake/3.18.4 intel_oneapi/compiler-rt32/latest intel_oneapi/tbb32/latestcmake/3.26.4 intel_oneapi/compiler/2024.1.0 intel_oneapi/vtune/2024.1cmake/3.29.1 intel_oneapi/compiler/latest intel_oneapi/vtune/latestcp2k/2023.1-gcc11 intel_oneapi/compiler32/2024.1.0 lammps/2024.02.07cp2k/2024.1-gcc11 intel_oneapi/compiler32/latest lapack/3.11.0-gcc11cuda/11.0-cvmfs intel_oneapi/dal/2024.0.0 lume-astra/0.6.1cuda/11.1-cvmfs intel_oneapi/dal/latest molpro/2015-gcc11cuda/11.2-cvmfs intel_oneapi/debugger/2024.1.0 mpi/mpich/4.1.3cuda/11.7-cvmfs intel_oneapi/debugger/latest mpi/mpich/4.2.1cuda/12.2-cvmfs intel_oneapi/dev-utilities/2024.0.0 mpi/mvapich/2.3.7cuda/12.4 intel_oneapi/dev-utilities/latest mpi/mvapich/3.4.3cuda/12.4-cvmfs intel_oneapi/dnnl/3.4.0 openmpi/4.1.4-gcc11cuDNN/8.0.5-cuda11.0 intel_oneapi/dnnl/latest orca/5.0.4-gcc11cuDNN/8.1.1-cuda11 intel_oneapi/dpct/2024.1.0 python/2.7.18cuDNN/8.9.7-cuda11 intel_oneapi/dpct/latest python/3.7.16cuDNN/8.9.7-cuda12 intel_oneapi/dpl/2022.5 python/3.8.19cuDNN/9.0.0-cuda11 intel_oneapi/dpl/latest python/3.9.18cuDNN/9.0.0-cuda12 intel_oneapi/ifort/2024.1.0 python/3.10.14elegant/1.0 intel_oneapi/ifort/latest python/3.11.8epics/7.0.7 intel_oneapi/ifort32/2024.1.0 python/3.12.2fftw/3.3.10-gcc11 intel_oneapi/ifort32/latest pytorch/2.0.1-cu117-py310gcc/7.5.0 intel_oneapi/intel_ipp_ia32/2021.11 pytorch/2.2.0-cu121-py310gcc/9.5.0 intel_oneapi/intel_ipp_ia32/latest quickpic/developgcc/10.4.0 intel_oneapi/intel_ipp_intel64/2021.11 scalapack/2.2.1gcc/11.4.0 intel_oneapi/intel_ipp_intel64/latest scow/1.0gcc/12.3.0 intel_oneapi/intel_ippcp_ia32/2021.11 tensorflow/2.4.0-cu110-py38gimic/2.0 intel_oneapi/intel_ippcp_ia32/latest tensorflow/2.11.0-cu112-py310gromacs/2023.4-gcc11 intel_oneapi/intel_ippcp_intel64/2021.11 tensorflow/2.15.0-cu122-py310hdf5/1.10.11 intel_oneapi/intel_ippcp_intel64/latest tensorflow/2.16.1-cu123-py310intel_oneapi/advisor/2024.1 intel_oneapi/mkl/2024.1 TensorRT/7.2.3.4-cuda11.0-cudnn8.1intel_oneapi/advisor/latest intel_oneapi/mkl/latest TensorRT/7.2.3.4-cuda11.1-cudnn8.1intel_oneapi/ccl/2021.12.0 intel_oneapi/mkl32/2024.1 TensorRT/8.6.1.6-cuda11.8intel_oneapi/ccl/latest intel_oneapi/mkl32/latest TensorRT/8.6.1.6-cuda12.0intel_oneapi/compiler-intel-llvm/2024.1.0 intel_oneapi/mpi/2021.12 TensorRT/10.0.1.6-cuda11.8intel_oneapi/compiler-intel-llvm/latest intel_oneapi/mpi/latest TensorRT/10.0.1.6-cuda12.4intel_oneapi/compiler-intel-llvm32/2024.1.0 intel_oneapi/oclfpga/2024.1.0 tfpwa/tf2.4.0intel_oneapi/compiler-intel-llvm32/latest intel_oneapi/oclfpga/latest vmd/1.9.4intel_oneapi/compiler-rt/2024.1.0 intel_oneapi/tbb/2021.12 warpx/24.02intel_oneapi/compiler-rt/latest intel_oneapi/tbb/latest

加载软件环境

moduleload# 例如:moduleloadcmake/3.18.4# 查看加载的 cmake 路径whichcmake

输出示例:

/cvmfs/slurm.ihep.ac.cn/alma9/anaconda3/envs/cmake-3.18.4/bin/cmake

查看已加载软件

modulelist

输出示例:

Currently Loaded Modulefiles:1) cmake/3.18.4

卸载软件环境

# 卸载指定的软件环境moduleunload# 例如:moduleunloadcmake/3.18.4# 卸载所有加载的软件环境modulepurge

查看 module 命令帮助

modulehelp

输出示例:

Modules Release 5.3.0 (2023-05-14)Usage: module [options] [command] [args ...]Loading / Unloading commands:add | load modulefile [...] Load modulefile(s)try-add | try-load modfile [...] Load modfile(s), no complain if not foundadd-any | load-any modfile [...] Load first available modulefile in listrm | unload modulefile [...] Remove modulefile(s)purge Unload all loaded modulefilesreload Unload then load all loaded modulefilesswitch | swap [mod1] mod2 Unload mod1 and load mod2refresh Refresh loaded module volatile componentsreset Restore initial environmentListing / Searching commands:list [-a] [-t|-l|-j] [-S|-C] [mod ...]List all or matching loaded modulesavail [-a] [-t|-l|-j] [-S|-C] [-d|-L] [--indepth|--no-indepth] [mod ...]List all or matching available modulesaliases [-a] List all module aliaseswhatis [-a] [-j] [modulefile ...] Print whatis information of modulefile(s)apropos | keyword | search [-a] [-j] strSearch all name and whatis containing stris-loaded [modulefile ...] Test if any of the modulefile(s) are loadedis-avail modulefile [...] Is any of the modulefile(s) availableinfo-loaded modulefile Get full name of matching loaded module(s)...

常见问题(FAQ)

见常见问题。

AI 助手
快速提问 ×

有问题?输入后跳转到对话页继续交流

Baidu
map