mirror of
https://gitee.com/ascend/MindSpeed-LLM.git
synced 2025-12-06 11:28:59 +08:00
3.7 KiB
3.7 KiB
安装指导
请参考首页依赖信息选择下载对应依赖版本。
注意:
1.torch2.6不支持python3.8,请优先使用python3.10;
2.qwen3, llama3.3系列模型要求高版本transformers,因此需要使用python3.10及以上版本;
驱动固件安装
下载驱动固件,请根据系统和硬件产品型号选择对应版本的driver和firmware。参考安装NPU驱动固件或执行以下命令安装:
chmod +x Ascend-hdk-<chip_type>-npu-driver_<version>_linux-<arch>.run
chmod +x Ascend-hdk-<chip_type>-npu-firmware_<version>.run
./Ascend-hdk-<chip_type>-npu-driver_<version>_linux-<arch>.run --full --force
./Ascend-hdk-<chip_type>-npu-firmware_<version>.run --full
CANN安装
下载CANN,请根据根据系统选择aarch64或x86_64对应版本的cann-toolkit、cann-kernel和cann-nnal。参考CANN安装或执行以下命令安装:
# 因为版本迭代,包名存在出入,根据实际修改
chmod +x Ascend-cann-toolkit_<version>_linux-<arch>.run
./Ascend-cann-toolkit_<version>_linux-<arch>.run --install
chmod +x Ascend-cann-kernels-<chip_type>_<version>_linux.run
./Ascend-cann-kernels-<chip_type>_<version>_linux.run --install
source /usr/local/Ascend/ascend-toolkit/set_env.sh # 安装nnal包需要source环境变量
chmod +x Ascend-cann-nnal-<chip_type>_<version>_linux.run
./Ascend-cann-nnal-<chip_type>_<version>_linux.run --install
# 设置环境变量
source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh
PTA安装
准备torch_npu和apex,执行以下命令安装或参考Ascend Extension for PyTorch 配置与安装:
# 安装torch和torch_npu 构建参考 https://gitee.com/ascend/pytorch/releases
pip install torch-2.6.0-cp310-cp310-manylinux_2_28_aarch64.whl
pip install torch_npu-2.6.0rc1-cp310-cp310-manylinux_2_28_aarch64.whl
# apex for Ascend 构建参考 https://gitee.com/ascend/apex
git clone -b master https://gitee.com/ascend/apex.git
cd apex/
bash scripts/build.sh --python={python_version}
cd apex/dist/
pip3 uninstall apex
pip3 install --upgrade apex-0.1+ascend-{version}.whl # version为python版本和cpu架构
MindSpeed-LLM及相关依赖安装
# 使能环境变量
source /usr/local/Ascend/ascend-toolkit/set_env.sh
source /usr/local/Ascend/nnal/atb/set_env.sh
# 安装MindSpeed加速库
git clone https://gitee.com/ascend/MindSpeed.git
cd MindSpeed
git checkout 2c085cc9 # checkout commit from MindSpeed core_r0.8.0 in 2025.04.01
pip install -r requirements.txt
pip3 install -e .
cd ..
# 准备MindSpeed-LLM及Megatron-LM源码
git clone https://gitee.com/ascend/MindSpeed-LLM.git
git clone https://github.com/NVIDIA/Megatron-LM.git # megatron从github下载,请确保网络能访问
cd Megatron-LM
git checkout core_r0.8.0
cp -r megatron ../MindSpeed-LLM/
cd ../MindSpeed-LLM
git checkout 2.1.0
pip install -r requirements.txt # 安装其余依赖库
注意:
1.qwen3, llama3.3系列模型依赖transformers 4.51.0, 需要在环境配置完成后手动执行pip install transformers==4.51.0;