From 099a932cbc968c5a737488656131544d85748dd4 Mon Sep 17 00:00:00 2001 From: MengqingCao Date: Tue, 28 May 2024 01:33:54 +0000 Subject: [PATCH 1/3] add Ascend npu doc and dependency Former-commit-id: cd67d6eeb55ca2a096e344ba43fc20d8b739f3f7 --- README.md | 20 +++++++++++++++++++- README_zh.md | 20 +++++++++++++++++++- setup.py | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcc96882..ca70110f 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,25 @@ To enable FlashAttention-2 on the Windows platform, you need to install the prec Join [NPU user group](assets/wechat_npu.jpg). -To utilize Ascend NPU devices for (distributed) training and inference, you need to install the **[torch-npu](https://gitee.com/ascend/pytorch)** library and the **[Ascend CANN Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. +Use `pip install -e .[torch_npu]` to install LLaMA-Factory with **[torch-npu](https://gitee.com/ascend/pytorch)** library. + +To utilize Ascend NPU devices for (distributed) training and inference, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. You can follow chapter **[install CANN](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)** in the installation tutorial to install CANN Toolkit and the kernels, or use the fast installation as following: + +```bash +# replace the url according to your choice +# install CANN Toolkit +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run +chmod +x Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run +./Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install + +# install CANN Kernels +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C18B800TP015/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +chmod +x Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +./Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install + +# set env variables +source /usr/local/Ascend/ascend-toolkit/set_env.sh +``` | Requirement | Minimum | Recommend | | ------------ | ------- | --------- | diff --git a/README_zh.md b/README_zh.md index 2e0b4f34..4f659588 100644 --- a/README_zh.md +++ b/README_zh.md @@ -347,7 +347,25 @@ pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/downl 加入 [NPU 用户群](assets/wechat_npu.jpg)。 -如果使用昇腾 NPU 设备进行(分布式)训练或推理,需要安装 **[torch-npu](https://gitee.com/ascend/pytorch)** 库和 **[Ascend CANN Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**。 +使用 `pip install -e .[torch_npu]` 来安装带有 **[torch-npu](https://gitee.com/ascend/pytorch)** 的 LLaMA-Factory。 + +如果使用昇腾 NPU 设备进行(分布式)训练或推理,需要安装 **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**。可以参考安装教程中的**[安装 CANN](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)**章节来进行安装,或使用以下快速安装指令: + +```bash +# 请替换 URL 为你需要的 CANN 版本对应的 URL +# 安装 CANN Toolkit +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run +chmod +x Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run +./Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install + +# 安装 CANN Kernels +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C18B800TP015/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +chmod +x Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +./Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install + +# 设置环境变量 +source /usr/local/Ascend/ascend-toolkit/set_env.sh +``` | 依赖项 | 至少 | 推荐 | | ------------ | ------- | --------- | diff --git a/setup.py b/setup.py index 4d948450..87620c37 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ extra_require = { "qwen": ["tiktoken", "transformers_stream_generator"], "modelscope": ["modelscope"], "quality": ["ruff"], + "torch_npu": ["torch==2.2.0", "torch_npu==2.2.0", "decorator"] } From 29fe1cd6887604e3ce91c645b49cc6f23696a8eb Mon Sep 17 00:00:00 2001 From: MengqingCao Date: Wed, 29 May 2024 09:53:31 +0000 Subject: [PATCH 2/3] update cann kernels url Former-commit-id: e14f5b37e4cf6086d80e600c88a4e2e402a74a72 --- README.md | 2 +- README_zh.md | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca70110f..14a8f4a2 100644 --- a/README.md +++ b/README.md @@ -359,7 +359,7 @@ chmod +x Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run ./Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install # install CANN Kernels -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C18B800TP015/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run chmod +x Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run ./Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install diff --git a/README_zh.md b/README_zh.md index 4f659588..66a4c031 100644 --- a/README_zh.md +++ b/README_zh.md @@ -359,7 +359,7 @@ chmod +x Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run ./Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install # 安装 CANN Kernels -wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C18B800TP015/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run +wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run chmod +x Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run ./Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install diff --git a/setup.py b/setup.py index 87620c37..f72eefb6 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ extra_require = { "qwen": ["tiktoken", "transformers_stream_generator"], "modelscope": ["modelscope"], "quality": ["ruff"], - "torch_npu": ["torch==2.2.0", "torch_npu==2.2.0", "decorator"] + "torch_npu": ["torch==2.1.0", "torch_npu==2.1.0", "decorator"] } From 2192616770f84977dcd32c047b66da6e6807c1d4 Mon Sep 17 00:00:00 2001 From: MengqingCao Date: Wed, 29 May 2024 10:05:11 +0000 Subject: [PATCH 3/3] update torch-npu version Former-commit-id: b19d33b9d205911ffd191bd0eadddd162b692e68 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f72eefb6..06e6b750 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ extra_require = { "qwen": ["tiktoken", "transformers_stream_generator"], "modelscope": ["modelscope"], "quality": ["ruff"], - "torch_npu": ["torch==2.1.0", "torch_npu==2.1.0", "decorator"] + "torch_npu": ["torch==2.1.0", "torch_npu==2.1.0.post3", "decorator"] }