昇腾社区首页
中文
注册
开发者
下载

总体说明

环境配置

环境依赖库参见如下:

  • nnae(8.0.0 <= version < 8.5.0)
  • python(version >= 3.9)
  • torch(version >= 2.0.1)
  • torch_npu(version >= 2.0.1.post4)
  • numpy(version >= 1.26.4)
  • scikit-learn(version >= 1.4.1.post1)
  • tqdm(version ≥ 4.66.1)

torch、torch_npu、numpy、scikit-learn和tqdm可通过pip install命令安装,执行命令参考如下。

1
pip install numpy tqdm scikit-learn torch_npu torch

CANN 8.5.0之前版本需要单独安装nnae具体安装步骤如下:

  1. 下载nnae软件包。
  2. 执行如下命令,增加可执行权限。
    chmod u+x ./Ascend-cann-nnae_{version}_linux-{arch}.run
  3. 执行如下命令,进行安装。
    ./Ascend-cann-nnae_{version}_linux-{arch}.run --install
  4. 按照安装提示信息设置环境变量。
    source /{nnae_installation_path}/nnae/set_env.sh

注意事项

  • 若import torch,torch_npu遇到下面的错误:
    1
    .../libgomp.so: cannot allocate memory in static TLS block
    

    请执行export LD_PRELOAD=.../libgomp.so(报错中出现的libgomp.so路径)

  • 若安装numpy出现pip无法安装如下依赖时:
    ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts.
    auto-tune 0.1.0 requires decorator, which is not installed.
    dataflow 0.0.1 requires jinja2, which is not installed.
    opc-tool 0.1.0 requires attrs, which is not installed.
    opc-tool 0.1.0 requires decorator, which is not installed.
    opc-tool 0.1.0 requires psutil, which is not installed.
    schedule-search 0.0.1 requires absl-py, which is not installed.
    schedule-search 0.0.1 requires decorator, which is not installed.
    te 0.4.0 requires attrs, which is not installed.
    te 0.4.0 requires cloudpickle, which is not installed.
    te 0.4.0 requires decorator, which is not installed.
    te 0.4.0 requires ml-dtypes, which is not installed.
    te 0.4.0 requires psutil, which is not installed.
    te 0.4.0 requires scipy, which is not installed.
    te 0.4.0 requires tornado, which is not installed.
    请执行以下命令。
    1
    pip install attrs cloudpickle decorator jinja2 ml-dtypes psutil scipy tornado absl-py
    
  • 若训练码本遇到以下问题:
    1
    2
    OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
    Segmentation fault (core dumped)
    
    请执行:
    1
    export OPENBLAS_NUM_THREADS=1
    

    该环境变量可能影响性能,码本训练完成后,建议设置回预设值。

  • --useOfflineCompile选项详细说明:
    在线算子编译耗时相比离线算子编译耗时较长。--useOfflineCompile选项用于控制是否使用离线算子编译,使用预先编译好的离线算子包执行。该方式需要用户提前安装单算子包。算子包安装指导如下:
    1. 下载算子软件包
    2. 执行如下命令,增加可执行权限。
      • CANN 8.5.0之前版本
        chmod u+x ./Ascend-cann-kernels-{chip_type}_{version}_linux-{arch}.run
      • CANN 8.5.0及之后版本
        chmod u+x ./Ascend-cann-{chip_type}-ops_{version}_linux-{arch}.run
    3. 执行如下命令,进行安装。
      • CANN 8.5.0之前版本
        ./Ascend-cann-kernels-{chip_type}_{version}_linux-{arch}.run --install
      • CANN 8.5.0及之后版本
        ./Ascend-cann-{chip_type}-ops_{version}_linux-{arch}.run --install
    4. 按照安装提示信息设置环境变量。
      • CANN 8.5.0之前版本
        source /{kernels_installation_path}/kernels/set_env.sh
      • CANN 8.5.0及之后版本
        source /usr/local/Ascend/cann/set_env.sh