环境变量配置
在开始训练前,需要先配置训练相关环境变量,用于配置昇腾NPU上的PyTorch训练环境,一般使用shell脚本配置,具体配置步骤与示例如下:
- 配置环境变量shell脚本,示例如下。
# 配置CANN相关环境变量 CANN_INSTALL_PATH_CONF='/etc/Ascend/ascend_cann_install.info' if [ -f $CANN_INSTALL_PATH_CONF ]; then DEFAULT_CANN_INSTALL_PATH=$(cat $CANN_INSTALL_PATH_CONF | grep Install_Path | cut -d "=" -f 2) else DEFAULT_CANN_INSTALL_PATH="/usr/local/Ascend/" fi CANN_INSTALL_PATH=${1:-${DEFAULT_CANN_INSTALL_PATH}} if [ -d ${CANN_INSTALL_PATH}/ascend-toolkit/latest ];then source ${CANN_INSTALL_PATH}/ascend-toolkit/set_env.sh else source ${CANN_INSTALL_PATH}/nnae/set_env.sh fi # 导入依赖库 export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/openblas/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib64/ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/aarch64_64-linux-gnu # 配置自定义环境变量 export HCCL_WHITELIST_DISABLE=1 # 关闭HCCL通信白名单 # 日志信息配置 export ASCEND_SLOG_PRINT_TO_STDOUT=0 # 日志打屏, 可选 export ASCEND_GLOBAL_LOG_LEVEL=3 # 日志级别常用 1 INFO级别; 3 ERROR级别 export ASCEND_GLOBAL_EVENT_ENABLE=0 # 默认不使能event日志信息
- 在拉起训练前,执行1配置的环境变量脚本。
source env.sh # env.sh为环境变量名称,用户需根据实际情况进行修改
父主题: 模型训练适配