Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c0d282932 | ||
|
|
ac3a639583 | ||
|
|
f7f2da79ec | ||
|
|
c60bbfba75 | ||
|
|
9477572064 | ||
|
|
473748343b | ||
|
|
228bec4413 | ||
|
|
3377df86c6 | ||
|
|
fff7b1265c | ||
|
|
27c077b266 | ||
|
|
fa53e4a2f2 | ||
|
|
2ae7e6f6a8 | ||
|
|
dc9be59e5e | ||
|
|
35f57d00dd | ||
|
|
214f6f98e9 | ||
|
|
7c29f6fb57 | ||
|
|
d1d3cd7ffd | ||
|
|
7456ef2606 | ||
|
|
4a3f61f367 | ||
|
|
9375223d4e | ||
|
|
e5ece794f3 | ||
|
|
1eb74061f4 | ||
|
|
2b4e64ac77 | ||
|
|
4b771736c1 | ||
|
|
dc8ba1c8ac | ||
|
|
abe5f8f9bb | ||
|
|
8c08296e01 | ||
|
|
b4366203ff | ||
|
|
8c4b448688 | ||
|
|
cc6c0ae868 | ||
|
|
6dc0c90fe5 | ||
|
|
85feca7020 | ||
|
|
f70fa2b749 | ||
|
|
3d86101802 | ||
|
|
58467c11f4 | ||
|
|
786492939f | ||
|
|
43fa745e6a | ||
|
|
94822276f9 | ||
|
|
9769e7e8f1 | ||
|
|
88b3d30fdb | ||
|
|
0522dfd0a3 | ||
|
|
7dc462c156 | ||
|
|
e9bab3c85a | ||
|
|
1437a9b04a | ||
|
|
7f4a31ec43 | ||
|
|
5c0980ac29 | ||
|
|
6942288239 | ||
|
|
72c74dbc9c | ||
|
|
1fdff7016b | ||
|
|
efa1ba2d70 | ||
|
|
ffbec8a589 | ||
|
|
df9b0d6a87 | ||
|
|
a557e2a19d | ||
|
|
052e47c1b4 | ||
|
|
dde486cd52 | ||
|
|
a6616a290f | ||
|
|
5c595d8685 | ||
|
|
efcf99e484 | ||
|
|
125ddd0a6b | ||
|
|
59f8b3bf0c | ||
|
|
5d67132cc7 | ||
|
|
684ce480c9 | ||
|
|
91e80eda14 | ||
|
|
dc29d26649 | ||
|
|
2728919061 | ||
|
|
1f2c7f2a56 | ||
|
|
1502202c48 | ||
|
|
d460e9c9fe | ||
|
|
14b0ede838 | ||
|
|
2c3648ea1c | ||
|
|
e73fb12b3d | ||
|
|
d5d67725ef | ||
|
|
efec73cde6 | ||
|
|
ca7a8c04af | ||
|
|
a68aab10ab | ||
|
|
ec8cc698f9 | ||
|
|
886e7defe3 | ||
|
|
8d079ca335 | ||
|
|
dd58af6101 | ||
|
|
b3a172415b | ||
|
|
35c09c5858 | ||
|
|
da90916ab0 | ||
|
|
12364d5728 | ||
|
|
eec0f1d6e1 | ||
|
|
8efe0da55e | ||
|
|
86b2def4fc | ||
|
|
86c8e6deb9 | ||
|
|
e966169b78 | ||
|
|
504fa67da2 | ||
|
|
37ee6fafaa | ||
|
|
cb11345fbe | ||
|
|
166c725588 | ||
|
|
4f4eaecb7f | ||
|
|
4603744324 | ||
|
|
501c17aade | ||
|
|
b998cd272d | ||
|
|
bed57e03c3 | ||
|
|
1cba4e9e8c | ||
|
|
ad7017491b | ||
|
|
548d08f5e9 | ||
|
|
0d362b2572 | ||
|
|
194352fe9e | ||
|
|
c718961328 | ||
|
|
67407fd00e | ||
|
|
fad4a75b37 | ||
|
|
035121e1fb | ||
|
|
82d7341955 | ||
|
|
8cd641382e | ||
|
|
c6648343a7 | ||
|
|
89a7a12a03 | ||
|
|
4eba985a2f | ||
|
|
ea8d8ad8c9 | ||
|
|
590e749dfe | ||
|
|
6a949ada88 | ||
|
|
40169ac353 | ||
|
|
c13ed77bd6 | ||
|
|
ea3dda5363 | ||
|
|
d52329f755 | ||
|
|
9a2ffe7dc5 | ||
|
|
6102b560d4 | ||
|
|
a704d91840 | ||
|
|
4dadfcf404 | ||
|
|
643cc072eb | ||
|
|
dc69d5441d | ||
|
|
12e6d9f07a | ||
|
|
f6b284d021 | ||
|
|
b87b437702 | ||
|
|
38675dbea0 | ||
|
|
e9a794a491 | ||
|
|
141d1b4c51 | ||
|
|
9961ec03ae | ||
|
|
e8e641b331 | ||
|
|
eb29fd3e36 | ||
|
|
0c5c61e3bc | ||
|
|
3708204f40 | ||
|
|
fbdf33ddd0 | ||
|
|
676978f973 | ||
|
|
6ff723d026 | ||
|
|
184db237b1 | ||
|
|
df03cbe8d6 | ||
|
|
02b5954125 | ||
|
|
c3723c6db0 | ||
|
|
2125edf662 | ||
|
|
273ab333eb | ||
|
|
e698adf379 | ||
|
|
172a8154f8 | ||
|
|
e6c9ed0c77 | ||
|
|
30951b3eda | ||
|
|
d938e07a73 | ||
|
|
8a5c0b30a1 | ||
|
|
262d785419 | ||
|
|
cebdde8f48 | ||
|
|
e9257ed887 | ||
|
|
e420c35be6 | ||
|
|
c5581b6189 | ||
|
|
f44d2a8710 | ||
|
|
4eb5bbd3fe | ||
|
|
0c58e128e7 | ||
|
|
0e1d68761b | ||
|
|
e161be6f75 | ||
|
|
40e0982fe4 | ||
|
|
3a36da0345 | ||
|
|
6a32513e71 | ||
|
|
3b92e80698 | ||
|
|
127ddaeb87 | ||
|
|
eb42aa1431 | ||
|
|
3a1a239c76 | ||
|
|
62c4f91fff | ||
|
|
ba0cdcc6f5 | ||
|
|
9d8ba72c9b | ||
|
|
77069c2c3e | ||
|
|
5510f37292 | ||
|
|
49aac16852 | ||
|
|
25b61ee2ee | ||
|
|
2ece9b72f6 | ||
|
|
2572775832 | ||
|
|
500b51dd61 | ||
|
|
bda7456cd9 | ||
|
|
040029c1a1 | ||
|
|
ec371989b4 | ||
|
|
ca59aaf3c6 | ||
|
|
78f946c17d | ||
|
|
ef4e7240b6 | ||
|
|
6ac16dfab0 | ||
|
|
283e923317 | ||
|
|
e6e7203cce | ||
|
|
6bb0e87a77 | ||
|
|
2497544a76 | ||
|
|
ae597b5e21 | ||
|
|
c0723277c4 | ||
|
|
64daba9637 | ||
|
|
d9e50e3a9f | ||
|
|
4dec0c82a1 | ||
|
|
e6b84a7986 | ||
|
|
f2e2a4168d | ||
|
|
92f9e54783 | ||
|
|
5d23983945 | ||
|
|
0850d4e22a | ||
|
|
c788e1a85c | ||
|
|
f414fe6e4c | ||
|
|
af726a697e | ||
|
|
afa8699efc | ||
|
|
89f71305c3 | ||
|
|
2bd42a661f | ||
|
|
88cbcb90dd | ||
|
|
706b56bf41 | ||
|
|
5f1e9f8cc8 | ||
|
|
4317ec1bca | ||
|
|
ace7ba9a8b | ||
|
|
8dc400cd8a | ||
|
|
f2c1df9134 | ||
|
|
728b16d171 | ||
|
|
6285b3b60f | ||
|
|
1017d89d57 | ||
|
|
424de74a3a | ||
|
|
7e05a39e42 | ||
|
|
24bfeaa78c | ||
|
|
47e8fac4ae | ||
|
|
c916024ec7 | ||
|
|
710ce99fa7 | ||
|
|
14f78e1593 | ||
|
|
ad48d8f66b | ||
|
|
5dee0e68b4 | ||
|
|
20034c4f3b | ||
|
|
ecd705896a | ||
|
|
a1297c462f | ||
|
|
04e467e6c2 | ||
|
|
33a911c624 | ||
|
|
14bd359387 | ||
|
|
52701635fa | ||
|
|
f8028e788f | ||
|
|
2e5af37b40 | ||
|
|
472a02ee7b | ||
|
|
03077bc002 | ||
|
|
8027eddae2 | ||
|
|
4e12aed2c4 | ||
|
|
d60a312292 | ||
|
|
ed5baac37f | ||
|
|
d3fca1bddd | ||
|
|
4082c74535 | ||
|
|
7b0b8cc5b9 | ||
|
|
bd49e63f36 | ||
|
|
c47ca17bee | ||
|
|
6e78d9b798 | ||
|
|
325e0c9686 | ||
|
|
8b46a4fa68 | ||
|
|
c927f4d52e | ||
|
|
a52a2a7582 | ||
|
|
28b81ba784 | ||
|
|
118cead9db | ||
|
|
37983612eb | ||
|
|
a0d5f0413a | ||
|
|
3f7654bb90 | ||
|
|
6f3c3f8c93 | ||
|
|
663e48a628 | ||
|
|
4c0b1766ab | ||
|
|
69547a0826 | ||
|
|
5b9b7041b2 | ||
|
|
bc0fbdcac9 | ||
|
|
ea561b97c9 | ||
|
|
f431153967 | ||
|
|
e82066018d | ||
|
|
a4fdc51ac9 | ||
|
|
42badebbad | ||
|
|
9d43973a43 | ||
|
|
9d4224f9a5 | ||
|
|
c2a7dc3f17 | ||
|
|
be21b4c339 | ||
|
|
851cc9e42e | ||
|
|
6963a9c6f5 | ||
|
|
f38ae2d871 | ||
|
|
cc3ebabbca | ||
|
|
d70ae50d78 | ||
|
|
f99298b02b | ||
|
|
8d64c91316 | ||
|
|
a40e37d953 | ||
|
|
5996fed7b1 | ||
|
|
3be7bcf63d | ||
|
|
6fc30ad19f | ||
|
|
81a39d545f | ||
|
|
75a9089e09 | ||
|
|
b256f3cfcd | ||
|
|
a03b990d2f | ||
|
|
b1de459aab | ||
|
|
78bb23dcfc | ||
|
|
358e163e2b | ||
|
|
e3cacd1240 | ||
|
|
5a675a23c2 | ||
|
|
62e6edd1be | ||
|
|
8b0bb12ed2 | ||
|
|
08895e3452 | ||
|
|
eb19e5be07 | ||
|
|
dbbb5b935b | ||
|
|
27b2513f2f | ||
|
|
18cee26cfb | ||
|
|
d9c203af66 | ||
|
|
a96f349728 | ||
|
|
08d67bb93b | ||
|
|
9d1f8c2062 | ||
|
|
e56d176f63 | ||
|
|
46d2c88c76 | ||
|
|
16c6efb99c | ||
|
|
3deb4f4041 | ||
|
|
63f22cf38d | ||
|
|
95bc96954a | ||
|
|
a323bfb26d | ||
|
|
4c28fae7ff | ||
|
|
d73f7d15d1 | ||
|
|
64142762fb | ||
|
|
2671012415 | ||
|
|
9cb88c4ae8 | ||
|
|
3015977115 | ||
|
|
25e1415cb4 | ||
|
|
9276d4c441 | ||
|
|
3ab4642abd | ||
|
|
aa1466742a | ||
|
|
9bfd72d468 | ||
|
|
0fa13028d3 | ||
|
|
358cba8b6d | ||
|
|
c684b7c74a | ||
|
|
d836a9cb3c | ||
|
|
369ebefd2e | ||
|
|
e1b754a902 | ||
|
|
c6ad5c5cc5 | ||
|
|
54af470c20 | ||
|
|
c56e5299d5 | ||
|
|
edfe8b0306 | ||
|
|
0143c1c06e | ||
|
|
fe09035482 | ||
|
|
e8f0e0055c | ||
|
|
255e1b94f6 | ||
|
|
b184e1c1d3 | ||
|
|
a85cb62301 | ||
|
|
1500208c7f | ||
|
|
073ad70cc4 | ||
|
|
6741696481 | ||
|
|
48dd2489e0 | ||
|
|
7e0b4081ac | ||
|
|
88d5c2c545 | ||
|
|
c39847cbba | ||
|
|
8fa79690b2 | ||
|
|
b6464ff2b2 | ||
|
|
a12b0dd319 | ||
|
|
b9c513ed2d | ||
|
|
e7218aaf60 | ||
|
|
5de5ce6d04 | ||
|
|
62992d4000 | ||
|
|
34f84c6ca4 | ||
|
|
4ebeb1fd6a | ||
|
|
c4c5da1ed0 | ||
|
|
4ad96e17f4 | ||
|
|
f6bd4ea357 | ||
|
|
6c52cd2a5d | ||
|
|
11ee398a57 | ||
|
|
c4c9340104 | ||
|
|
931f3c3878 | ||
|
|
a48b4fd558 | ||
|
|
d44bc70aae | ||
|
|
021efdf1da | ||
|
|
1d607dcf4f | ||
|
|
b2afdd7871 | ||
|
|
37fc10168a | ||
|
|
6432bc6349 | ||
|
|
4160ab8ab6 | ||
|
|
afaa4d4e88 | ||
|
|
91014cd3b8 | ||
|
|
798f0c3b16 | ||
|
|
c28c47c9cd | ||
|
|
bda914c574 | ||
|
|
edb5c70443 | ||
|
|
4689a0514b | ||
|
|
63950d1412 | ||
|
|
16fb2692c6 | ||
|
|
193cd1f80d | ||
|
|
6b5302218a |
@@ -18,6 +18,7 @@
|
||||
|
||||
- 在[Gitee](https://gitee.com/ascend/pytorch)上Fork存储库。
|
||||
- 阅读[README.md](#https://gitee.com/ascend/pytorch/blob/master/README.zh.md)以获取项目信息和构建说明。
|
||||
- 行为准则 [coc](https://gitee.com/ascend/community/blob/master/code-of-conduct_zh_cn.md)。
|
||||
|
||||
<h2 id="开发指导.md">开发指导</h2>
|
||||
|
||||
@@ -98,7 +99,7 @@
|
||||
|
||||
2. 设置环境变量。
|
||||
|
||||
进入“pytorh/src“路径,并执行env.sh脚本。
|
||||
进入"pytorch/src"路径,并执行env.sh脚本。
|
||||
|
||||
```
|
||||
bash env.sh
|
||||
@@ -119,11 +120,11 @@
|
||||
|
||||
- 编码指南
|
||||
|
||||
请在PyTorch社区使用规统一的编码分格,_Python__中_建议的编码风格是[PEP 8编码样式](https://pep8.org/),_C++_编码所建议的风格是 [Google C++编码指南](http://google.github.io/styleguide/cppguide.html) 。可以使用[CppLint](https://github.com/cpplint/cpplint),[CppCheck](http://cppcheck.sourceforge.net/),[CMakeLint](https://github.com/cmake-lint/cmake-lint),[CodeSpell](https://github.com/codespell-project/codespell), [Lizard](http://www.lizard.ws/),[ShellCheck](https://github.com/koalaman/shellcheck)和[pylint](https://pylint.org/)检查代码的格式,建议在您的IDE中安装这些插件。
|
||||
请在PyTorch社区使用规统一的编码分格,python建议的编码风格是[PEP 8编码样式](https://pep8.org/),C++编码所建议的风格是 [Google C++编码指南](http://google.github.io/styleguide/cppguide.html) 。可以使用[CppLint](https://github.com/cpplint/cpplint),[CppCheck](http://cppcheck.sourceforge.net/),[CMakeLint](https://github.com/cmake-lint/cmake-lint),[CodeSpell](https://github.com/codespell-project/codespell), [Lizard](http://www.lizard.ws/),[ShellCheck](https://github.com/koalaman/shellcheck)和[pylint](https://pylint.org/)检查代码的格式,建议在您的IDE中安装这些插件。
|
||||
|
||||
- 单元测试指南
|
||||
|
||||
请在PyTorch社区使用统一的单元测试风格, _Python_中建议的单元测试风格是[pytest](http://www.pytest.org/en/latest/),_C++_单元测试所建议的风格是 [Googletest Primer](#https://github.com/google/googletest/blob/master/docs/primer.md) 。测试用例的设计意图应该通过它的注释名称来反映。
|
||||
请在PyTorch社区使用统一的单元测试风格, Python中建议的单元测试风格是[pytest](http://www.pytest.org/en/latest/),C++单元测试所建议的风格是 [Googletest Primer](#https://github.com/google/googletest/blob/master/docs/primer.md) 。测试用例的设计意图应该通过它的注释名称来反映。
|
||||
|
||||
- 重构指南
|
||||
|
||||
@@ -165,7 +166,7 @@
|
||||
|
||||
3. 本地开发代码。
|
||||
|
||||
为了避免多个分支之间的不一致,建议签出到一个新的分支:
|
||||
为了避免多个分支之间的不一致,建议创建新的分支进行开发:
|
||||
|
||||
```
|
||||
git checkout -b {new_branch_name} origin/master
|
||||
@@ -185,7 +186,7 @@
|
||||
git push origin {new_branch_name}
|
||||
```
|
||||
|
||||
5. 向 PyTorh存储库拉取请求。
|
||||
5. 向 PyTorch存储库拉取请求。
|
||||
|
||||
在最后一步中,您需要在新分支和“PyTorch master“分支之间拉取比较请求。完成拉取请求后,“Jenkins CI“将自动设置为构建测试。您的pull request应该尽快合并到上游 master 分支,以降低合并的风险。
|
||||
|
||||
@@ -224,4 +225,3 @@
|
||||
- 确保你的提交历史被排序。
|
||||
- 始终将您的分支与主分支保持一致。
|
||||
- 对于错误修复 PR,请确保链接所有相关问题。
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2021, 张昱杰
|
||||
Copyright (c) 2020, Huawei Technologies Co., Ltd
|
||||
Copyright (c) 2019, Facebook CORPORATION.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
approvers:
|
||||
- blian
|
||||
- nalinaly
|
||||
- weili10
|
||||
reviewers:
|
||||
- zhou_sinan
|
||||
- shibo19
|
||||
@@ -13,4 +14,7 @@ reviewers:
|
||||
- wangyu0516
|
||||
- yskhhh
|
||||
- lvpeiyuan
|
||||
- xchu42
|
||||
- xchu42
|
||||
- goodjobwubai
|
||||
- fairwarning
|
||||
- yinzijun
|
||||
@@ -0,0 +1,278 @@
|
||||
# AscendPyTorch
|
||||
|
||||
|
||||
# Project Introduction
|
||||
This project develops the PyTorch Adapter plugin to adapt Ascend to the PyTorch framework so that developers who use the PyTorch framework can obtain powerful compute capabilities of Ascend AI Processors.
|
||||
|
||||
# Compilation/Execution Constraints
|
||||
|
||||
GCC version: 7.3.0 (required only in compilation scenarios)
|
||||
|
||||
CMake version: 3.12.0 or later (required only in compilation scenarios)
|
||||
|
||||
Python versions: 3.7.5 and 3.8.*x* (The compilation methods are different. For details, see the script compilation section.)
|
||||
|
||||
|
||||
# System Dependencies
|
||||
|
||||
## CentOS & EulerOS
|
||||
|
||||
yum install -y cmake zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas
|
||||
|
||||
## Ubuntu
|
||||
|
||||
apt-get install -y gcc g++ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev m4 cmake dos2unix libopenblas-dev
|
||||
|
||||
|
||||
# Ascend Auxiliary Software
|
||||
|
||||
| AscendPyTorch Version| CANN Version| Supported PyTorch Version|
|
||||
| :---------------- | :--------- | :------------------------------- |
|
||||
| 2.0.2 | CANN 5.0.2 | 1.5.0 |
|
||||
| 2.0.3 | CANN 5.0.3 | 1.5.0 and 1.8.1 (Only the ResNet-50 model is supported.)|
|
||||
| 2.0.4 | CANN 5.0.4 | 1.5.0 and 1.8.1 (Only the ResNet-50 model is supported.)|
|
||||
|
||||
# Method of Use - Full Code Generation and Compilation
|
||||
|
||||
## Obtain the native PyTorch source code and third-party code.
|
||||
|
||||
Currently, PyTorch 1.5.0 and 1.8.1 are supported. Obtain the native PyTorch source code from the root directory **pytorch/** in the current repository as required.
|
||||
|
||||
```sh
|
||||
git clone https://gitee.com/ascend/pytorch.git
|
||||
# By default, the masterf branch is used. If other branches are required, run the git checkout command to switch to that branch.
|
||||
cd pytorch
|
||||
git checkout -b 2.0.4.tr5 remotes/origin/2.0.4.tr5
|
||||
```
|
||||
|
||||
Obtain the native PyTorch source code from the root directory **/pytorch** of the current repository.
|
||||
|
||||
```sh
|
||||
// Version 1.5.0
|
||||
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
// Version 1.8.1
|
||||
git clone -b v1.8.1 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
```
|
||||
|
||||
Go to the **pytorch/pytorch/** directory and obtain the passive dependency code of PyTorch. (It takes a long time to obtain the code.)
|
||||
|
||||
```sh
|
||||
cd pytorch
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
If no error is reported after the preceding operations are complete, the PyTorch and third-party code on which PyTorch depends is generated.
|
||||
|
||||
## Generate the PyTorch code adapted to Ascend AI Processors.
|
||||
|
||||
Go to the **pytorch/scripts** directory and run the script based on the selected version. (Note: The downloaded native PyTorch source code must match the following version. Otherwise, an error may occur.)
|
||||
|
||||
```sh
|
||||
cd ../scripts
|
||||
// The default version is 1.5.0.
|
||||
bash gen.sh
|
||||
// For version 1.8.1, use the -v option to specify the version number.
|
||||
bash gen.sh -v 1.8.1
|
||||
```
|
||||
|
||||
The full code adapted to NPUs is generated in the **pytorch/pytorch/** directory.
|
||||
|
||||
|
||||
## Install the Python dependency.
|
||||
|
||||
Go to the **pytorch/pytorch/** directory and install the Python dependency.
|
||||
|
||||
```python3
|
||||
cd ../pytorch
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## Compile the binary package of Torch.
|
||||
|
||||
Go to the **pytorch/pytorch/** directory and run the following command:
|
||||
|
||||
```sh
|
||||
# Python 3.7
|
||||
bash build.sh
|
||||
or
|
||||
bash build.sh --python=3.7 (recommended)
|
||||
|
||||
# Python 3.8
|
||||
bash build.sh --python=3.8
|
||||
```
|
||||
|
||||
The generated binary package is in the **pytorch/pytorch/dist/** directory.
|
||||
|
||||
# Installation
|
||||
|
||||
### (Version 1.5.0 is used as an example. The same rule applies to version 1.8.1.)
|
||||
|
||||
**x86_64:**
|
||||
|
||||
**torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_x86_64.whl**.)
|
||||
|
||||
```shell
|
||||
cd dist
|
||||
pip3 uninstall torch
|
||||
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
|
||||
```
|
||||
|
||||
**arm:**
|
||||
|
||||
**torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_aarch64.whl**.)
|
||||
|
||||
```shell
|
||||
cd dist
|
||||
pip3 uninstall torch
|
||||
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
|
||||
```
|
||||
|
||||
|
||||
# Running
|
||||
|
||||
## Execute environment variables.
|
||||
|
||||
Run the script for setting environment variables in the root directory of the current repository.
|
||||
|
||||
```
|
||||
cd ../
|
||||
source env.sh
|
||||
```
|
||||
|
||||
|
||||
## Customize environment variables.
|
||||
|
||||
The following environment variables are function classes used in NPU scenarios or environment variables that can improve performance:
|
||||
|
||||
```
|
||||
export TASK_QUEUE_ENABLE=1 # Delivered by an asynchronous task to asynchronously call the ACL interface. You are advised to enable this environment variable and set its value to 1 when there is a bottleneck in the delivery of tasks.
|
||||
export PTCOPY_ENABLE=1 # Use the PTCopy operator mode to accelerate continuous rotation and copy. You are advised to enable this environment variable and set its value to 1.
|
||||
```
|
||||
|
||||
The following are optional environment variables that may affect running models:
|
||||
|
||||
```
|
||||
export DYNAMIC_COMPILE_ENABLE=1 # Dynamic shape feature. This environment variable is optional for shape change scenarios. To enable it, set its value to 1.
|
||||
export COMBINED_ENABLE=1 # Optimization of scenarios where two inconsecutive operators are combined. This environment variable is optional. To enable it, set its value to 1.
|
||||
export TRI_COMBINED_ENABLE=1 # Optimization of scenarios where three inconsecutive operators are combined. This environment variable is optional. To enable it, set its value to 1.
|
||||
export ACL_DUMP_DATA=1 # Operator data dump function, which is used for debugging. This environment variable is optional. To enable it, set its value to 1.
|
||||
export DYNAMIC_OP="ADD#MUL" # Operator implementation. The ADD and MUL operators have different performance in different scenarios. This environment variable is optional.
|
||||
```
|
||||
|
||||
|
||||
## Run the unit test script.
|
||||
|
||||
Verify the execution. The output result is OK.
|
||||
|
||||
```shell
|
||||
// Select a test script that matches the preceding version. The following uses the 1.5.0 version as an example.
|
||||
python3 pytorch1.5.0/test/test_npu/test_network_ops/test_div.py
|
||||
// The following uses the 1.8.1 version as an example.
|
||||
python3 pytorch1.8.1/test/test_npu/test_network_ops/test_div.py
|
||||
```
|
||||
|
||||
# Documentation
|
||||
|
||||
For more details about the installation guide, model porting and training/inference tutorials, and API list, see [User Documents](https://gitee.com/ascend/pytorch/tree/master/docs/en).
|
||||
|
||||
# Suggestions and Communication
|
||||
|
||||
We sincerely welcome you to join discussions in the community and contribute your suggestions. We will reply to you as soon as possible.
|
||||
|
||||
# Branch Maintenance Policies
|
||||
|
||||
The version branches of AscendPyTorch have the following maintenance phases:
|
||||
|
||||
| **Status**| **Duration**| **Description**|
|
||||
| ----------------- | ------------- | -------------------------------------------------- |
|
||||
| Planning | 1 - 3 months | Plan features.|
|
||||
| Development | 3 months | Develop features.|
|
||||
| Maintained | 6 - 12 months | Allow the incorporation of all resolved issues and release the version.|
|
||||
| Unmaintained | 0 - 3 months | Allow the incorporation of all resolved issues. No dedicated maintenance personnel are available. No version will be released.|
|
||||
| End Of Life (EOL) | N/A | Do not accept any modifications to a branch. |
|
||||
|
||||
# Maintenance Status of Existing Branches
|
||||
|
||||
| **Branch Name**| **Status**| **Launch Date**| **Subsequent Status**| **EOL Date**|
|
||||
| ---------- | ------------ | ------------ | -------------------------------------- | ------------ |
|
||||
| **v2.0.2** | Maintained | 2021-07-29 | Unmaintained <br> 2022-07-29 estimated | |
|
||||
| **v2.0.3** | Maintained | 2021-10-15 | Unmaintained <br> 2022-10-15 estimated | |
|
||||
| **v2.0.4** | Maintained | 2022-11-15 | Unmaintained <br> 2023-01-15 estimated | |
|
||||
|
||||
|
||||
# FAQs
|
||||
|
||||
## The error message "no module named yaml/typing_extensions." is displayed when **bash build.sh** is run during compilation.
|
||||
|
||||
PyTorch compilation depends on the YAML and typing_extensions libraries, which need to be manually installed.
|
||||
|
||||
```
|
||||
pip3 install pyyaml
|
||||
pip3 install typing_extensions
|
||||
```
|
||||
|
||||
After the installation is successful, run **make clean** and then **bash build.sh** to perform compilation. Otherwise, an unknown compilation error may occur due to the cache.
|
||||
|
||||
## TE cannot be found during running
|
||||
|
||||
Development state:
|
||||
|
||||
```
|
||||
cd /urs/local/Ascend/ascend-toolkit/latest/{arch}-linux/lib64
|
||||
```
|
||||
|
||||
User state:
|
||||
|
||||
```
|
||||
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64
|
||||
|
||||
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
|
||||
|
||||
pip3 install --upgrade te-0.4.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
|
||||
|
||||
## An error message is reported during CMake compilation, indicating that the version is too early.
|
||||
|
||||
Download the Linux version from the CMake official website and install it. (The current version is 3.18.0.)
|
||||
|
||||
1. Run the **yum install -y cmake==3.18.0** command to install it.
|
||||
|
||||
2. Download the **cmake sh** script and install it. (For details, see the CMake official website.)
|
||||
|
||||
Recommended script in the x86_64 environment: **cmake-3.18.2-Linux-x86_64.sh**
|
||||
|
||||
|
||||
|
||||
## GCC version switch errors occur.
|
||||
|
||||
When the test environment is switched from GCC 4.8.5 to GCC 7.3.0, errors may occur and the PyTorch compilation may fail. The following lists the libraries that require soft connections:
|
||||
|
||||
gcc, g++, c++ (The version must be 7.3.0.)
|
||||
|
||||
libstdc++->libstdc++.so.6.0.24 (7.3.0)
|
||||
|
||||
|
||||
|
||||
## libblas.so cannot be found.
|
||||
|
||||
The OpenBLAS library is missing in the environment. You need to install it.
|
||||
|
||||
CentOS and EulerOS
|
||||
|
||||
```sh
|
||||
yum -y install openblas
|
||||
```
|
||||
|
||||
Ubuntu
|
||||
|
||||
```sh
|
||||
apt install libopenblas-dev
|
||||
```
|
||||
|
||||
# Release Notes
|
||||
|
||||
For details, see [Release Notes](https://gitee.com/ascend/pytorch/tree/master/docs/en/RELEASENOTE).
|
||||
@@ -10,7 +10,7 @@ gcc版本: 7.3.0(只在编译场景要求)
|
||||
|
||||
cmake版本:3.12.0以上版本(只在编译场景要求)
|
||||
|
||||
python版本:3.7.x
|
||||
python版本:3.7.5 和 3.8.x(编译方法有差别,详见脚本编译章节)
|
||||
|
||||
|
||||
# 系统依赖库
|
||||
@@ -24,62 +24,99 @@ yum install -y cmake zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel g
|
||||
apt-get install -y gcc g++ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev m4 cmake dos2unix libopenblas-dev
|
||||
|
||||
|
||||
# python依赖库
|
||||
|
||||
|
||||
依赖库安装:
|
||||
|
||||
```python3
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
# Ascend配套软件
|
||||
|
||||
| AscendPyTorch版本 | CANN版本 | 支持PyTorch版本 |
|
||||
| :------------ | :----------- | :----------- |
|
||||
| 2.0.2 | CANN 5.0.2 | 1.5.0 |
|
||||
| 2.0.3 | CANN 5.0.3 | 1.5.0,1.8.1(仅支持resnet50模型) |
|
||||
| 2.0.4 | CANN 5.0.4 | 1.5.0,1.8.1(仅支持resnet50模型) |
|
||||
|
||||
# 使用方式 --生成全量代码并编译
|
||||
|
||||
## 获取适配昇腾AI处理器的PyTorch源代码patch
|
||||
|
||||
获取适配昇腾AI处理器的PyTorch源代码(即当前仓库代码),并切换到所需的分支。
|
||||
|
||||
```
|
||||
git clone https://gitee.com/ascend/pytorch.git
|
||||
# 默认是master分支,若需要其他分支请使用git checkout 命令切换
|
||||
cd pytorch
|
||||
git checkout -b 2.0.4.tr5 remotes/origin/2.0.4.tr5
|
||||
```
|
||||
|
||||
## 获取原生PyTorch源代码和third_party代码
|
||||
|
||||
在当前仓库根目录pytorch/下获取原生PyTorch的源代码
|
||||
当前支持pytorch 1.5.0和1.8.1的版本。根据需求,在当前仓库根目录pytorch/下获取原生PyTorch的源代码
|
||||
|
||||
```sh
|
||||
// 1.5.0 版本
|
||||
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
// 1.8.1 版本
|
||||
git clone -b v1.8.1 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
```
|
||||
|
||||
进入到pytorch/pytorch/目录下, 获取PyTorch被动依赖代码(获取时间较长,请耐心等待)。
|
||||
|
||||
```sh
|
||||
cd pytorch
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
完成且没有报错之后就生成了PyTorch及其依赖的三方代码
|
||||
|
||||
## 生成适配昇腾AI处理器的PyTorch代码。
|
||||
## 生成适配昇腾AI处理器的PyTorch全量代码。
|
||||
|
||||
进入到pytorch/scripts目录,执行
|
||||
进入到pytorch/scripts目录,根据选择的版本执行,执行脚本(注意:下载原生Pytorch源代码和下面版本要对应,否则可能出错)
|
||||
|
||||
```sh
|
||||
cd ../scripts/
|
||||
// 默认为1.5.0版本
|
||||
bash gen.sh
|
||||
// 对于1.8.1版本,则通过-v 参数指定
|
||||
bash gen.sh -v 1.8.1
|
||||
```
|
||||
|
||||
会在pytorch/pytorch/目录中生成npu适配全量代码
|
||||
|
||||
|
||||
## python依赖库
|
||||
|
||||
进入到pytorch/pytorch/目录,依赖库安装:
|
||||
|
||||
```python3
|
||||
cd ../pytorch/
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## 编译torch的二进制包
|
||||
|
||||
进入到pytorch/pytorch/目录,执行
|
||||
|
||||
```sh
|
||||
# python3.7版本
|
||||
bash build.sh
|
||||
或者
|
||||
bash build.sh --python=3.7(推荐)
|
||||
|
||||
# python3.8版本
|
||||
bash build.sh --python=3.8
|
||||
```
|
||||
|
||||
生成的二进制包在pytorch/pytorch/dist/目录下
|
||||
|
||||
# 安装
|
||||
|
||||
### (以1.5.0版本为例,1.8.1版本同理)
|
||||
|
||||
**x86_64:**
|
||||
|
||||
torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl (实际可能附带小版本号例如torch-1.5.0.post2+ascend-cp37-cp37m-linux_x86_64.whl)
|
||||
|
||||
```python
|
||||
```shell
|
||||
cd dist/
|
||||
pip3 uninstall torch
|
||||
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
|
||||
```
|
||||
@@ -89,7 +126,8 @@ pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
|
||||
|
||||
torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl (实际可能附带小版本号例如torch-1.5.0.post2+ascend-cp37-cp37m-linux_aarch64.whl)
|
||||
|
||||
```python
|
||||
```shell
|
||||
cd dist/
|
||||
pip3 uninstall torch
|
||||
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
|
||||
```
|
||||
@@ -102,7 +140,8 @@ pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
|
||||
在当前仓库根目录中执行设置环境变量脚本
|
||||
|
||||
```
|
||||
source src/env.sh
|
||||
cd ../
|
||||
source pytorch/env.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -111,7 +150,7 @@ source src/env.sh
|
||||
以下环境变量为NPU场景下使用的功能类或可以提升性能的环境变量:
|
||||
|
||||
```
|
||||
export TASK_QUEUE_ENABLE=1 # 使用异步任务下发,异步调用acl接口,建议默认开启,开启设置为1
|
||||
export TASK_QUEUE_ENABLE=1 # 使用异步任务下发,异步调用acl接口,主机侧任务下发出现瓶颈时建议开启,开启设置为1
|
||||
export PTCOPY_ENABLE=1 # 使用PTCopy算子模式,加速转连续及copy等过程,建议默认开启,开启设置为1
|
||||
```
|
||||
|
||||
@@ -130,47 +169,62 @@ export DYNAMIC_OP="ADD#MUL" # 算子实现,ADD和MUL算子在不同场景下
|
||||
|
||||
验证运行, 输出结果OK
|
||||
|
||||
```python
|
||||
python3 test/test_npu/test_div.py
|
||||
```shell
|
||||
// 根据前述版本,选择对应的测试脚本,以下为1.5.0版本
|
||||
python3 pytorch1.5.0/test/test_npu/test_network_ops/test_div.py
|
||||
// 以下为1.8.1版本
|
||||
python3 pytorch1.8.1/test/test_npu/test_network_ops/test_div.py
|
||||
```
|
||||
|
||||
# 路标
|
||||
# 文档
|
||||
|
||||
以下将展示AscendPyTorch近期的计划,我们会根据用户的反馈诉求,持续调整计划的优先级。
|
||||
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[用户文档](docs/zh)。
|
||||
|
||||
总体而言,我们会努力在以下几个方面不断改进。
|
||||
# 建议与交流
|
||||
|
||||
1、pytorch AICPU多核能力补齐
|
||||
|
||||
2、pytorch单算子模式const节点输入
|
||||
|
||||
3、pytorch场景支持算子非连续输入
|
||||
|
||||
4、pytorch单算子模式支持动态shape
|
||||
|
||||
5、NLP网络格式转化方案完善
|
||||
|
||||
6、pytorch的基线格式调整
|
||||
|
||||
7、reshapeType总体方案梳理优化
|
||||
|
||||
8、AICPU针对pytorch方案梳理优化
|
||||
热忱希望各位在用户社区加入讨论,并贡献您的建议,我们会尽快给您回复。
|
||||
|
||||
热忱希望各位在用户社区加入讨论,并贡献您的建议。
|
||||
# 分支维护策略
|
||||
|
||||
Ascend PyTorch的版本分支有以下几种维护阶段:
|
||||
|
||||
| **状态** | **持续时间** | **说明** |
|
||||
|-------------|---------------|--------------------------------------------------|
|
||||
| Planning | 1 - 3 months | 特性规划。 |
|
||||
| Development | 3 months | 特性开发。 |
|
||||
| Maintained | 6 - 12 months | 允许所有问题修复的合入,并发布版本。 |
|
||||
| Unmaintained| 0 - 3 months | 允许所有问题修复的合入,无专人维护,不再发布版本。 |
|
||||
| End Of Life (EOL) | N/A | 不再接受修改合入该分支。 |
|
||||
|
||||
# 现有分支维护状态
|
||||
|
||||
| **分支名** | **当前状态** | **上线时间** | **后续状态** | **EOL 日期**|
|
||||
|------------|--------------|----------------------|----------------------------------------|------------|
|
||||
| **v2.0.2** | Maintained | 2021-07-29 | Unmaintained <br> 2022-07-29 estimated | |
|
||||
| **v2.0.3** | Maintained | 2021-10-15 | Unmaintained <br> 2022-10-15 estimated | |
|
||||
| **v2.0.4** | Maintained | 2022-01-15 | Unmaintained <br> 2023-01-15 estimated | |
|
||||
|
||||
|
||||
# FAQ
|
||||
|
||||
## 编译过程执行bash build.sh报错no module named yaml/typing_extensions.
|
||||
|
||||
pytorch编译依赖 yaml库和typing_extensions库,需要手动安装。
|
||||
|
||||
pip3 install pyyaml
|
||||
pip3 install typing_extensions
|
||||
|
||||
安装成功后,注意需要执行make clean在执行bash build.sh进行编译,否则可能因缓存出现未知编译错误。
|
||||
|
||||
## 运行遇到找不到te问题
|
||||
|
||||
开发态:
|
||||
|
||||
cd /urs/local/ascend-toolkit/latest/fwkacllib/lib64
|
||||
cd /urs/local/Ascend/ascend-toolkit/latest/{arch}-linux/lib64
|
||||
|
||||
用户态:
|
||||
|
||||
cd /urs/local/nnae/latest/fwkacllib/lib64
|
||||
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64
|
||||
|
||||
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
|
||||
|
||||
@@ -216,3 +270,6 @@ Ubuntu环境
|
||||
apt install libopenblas-dev
|
||||
```
|
||||
|
||||
# 版本说明
|
||||
|
||||
版本说明请参阅[ReleseNote](docs/zh/RELEASENOTE)
|
||||
@@ -0,0 +1,85 @@
|
||||
OPEN SOURCE SOFTWARE NOTICE
|
||||
|
||||
Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country.
|
||||
|
||||
Warranty Disclaimer
|
||||
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
||||
|
||||
Copyright Notice and License Texts
|
||||
|
||||
Software: pytorch 1.5.0
|
||||
Copyright notice:
|
||||
Copyright (c) 2016-present, Facebook, Inc.
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
Copyright 2006, Google Inc.
|
||||
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
|
||||
2017-2018 Advanced Micro Devices, Inc. and Facebook Inc. All rights reserved.
|
||||
Copyright 2004-present Facebook. All Rights Reserved.
|
||||
Copyright (c) 2018 MathInf GmbH, Thomas Viehmann
|
||||
Copyright (c) 2014 Indiana University
|
||||
Copyright (c) 2016, NVIDIA CORPORATION, All rights reserved
|
||||
Copyright (C) 2012 Giovanni Garberoglio
|
||||
Copyright 2015 Google Inc. All Rights Reserved.
|
||||
Copyright (c) Facebook Inc. and Microsoft Corporation.
|
||||
Copyright © 2001-2014 Python Software Foundation
|
||||
All Rights Reserved
|
||||
Copyright (c) 2014-2015 The Khronos Group Inc.
|
||||
Copyright (c) 2006, Laurent Montel, montel@kde.org
|
||||
Copyright 2013 Conrad Steenberg conrad.steenberg@gmail.com
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
Copyright (c) 2010-2017 Benjamin Peterson
|
||||
Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||
Copyright (c) 2007-2009 Scientific Computing and Imaging Institute, University of Utah
|
||||
(c) Facebook, Inc. and its affiliates. Confidential and proprietary.
|
||||
Copyright (c) 2017 by Contributors
|
||||
Copyright 2016 Facebook
|
||||
Copyright (C) 2018 Marat Dukhan
|
||||
Copyright (c) 2017-2018 Facebook Inc.
|
||||
Copyright (c) 2017 Georgia Institute of Technology
|
||||
Copyright (c) 2016 Microsoft
|
||||
Copyright (c) 2014, 2015, The Regents of the University of California
|
||||
Copyright (c) 2014, 2015, the respective contributors
|
||||
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
|
||||
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
|
||||
Copyright (c) 2011-2013 NYU (Clement Farabet)
|
||||
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert,Leon Bottou, Iain Melvin, Jason Weston)
|
||||
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
|
||||
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert,Samy Bengio, Johnny Mariethoz)
|
||||
Copyright (c) 2016-2017, ARM Limited and Contributors
|
||||
Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
Copyright (C) 2007-2017 Free Software Foundation, Inc.
|
||||
Copyright Malte Skarupke 2017.
|
||||
Copyright (C) 2011 - 2012 Andrzej Krzemienski.
|
||||
Copyright (C) 2001-2019 Free Software Foundation, Inc.
|
||||
Copyright (c) 1994 Hewlett-Packard Company
|
||||
Copyright (c) 1996-1998 Silicon Graphics Computer Systems, Inc.
|
||||
Copyright Michael Park, 2015-2017
|
||||
Copyright (c) 2008 - 2012 The Khronos Group Inc.
|
||||
Copyright (c) 2008-2013 The Khronos Group Inc.
|
||||
Copyright (c) 2008-2012 The Khronos Group Inc.
|
||||
Copyright (C) 2006 The Android Open Source Project
|
||||
Copyright (c) 2016- Facebook, Inc (Adam Paszke)
|
||||
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
|
||||
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
|
||||
Copyright (c) 2011-2013 NYU (Clement Farabet)
|
||||
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
|
||||
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
|
||||
Copyright (c) 2016-present, Facebook Inc. All rights reserved.
|
||||
Copyright (c) 2016 Facebook Inc.
|
||||
Copyright (c) 2015 Google Inc.
|
||||
Copyright (c) 2015 Yangqing Jia
|
||||
Copyright(c) 2013, 2014, 2015, the respective contributors
|
||||
Copyright(c) 2015, 2016 the respective contributors
|
||||
Copyright (c) 2014, The Regents of the University of California (Regents)
|
||||
Copyright (c) 2014, the respective contributors
|
||||
Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
Copyright (c) 2014-2017 The Regents of the University of California (Regents)
|
||||
Copyright (c) 2014-2017, the respective contributors
|
||||
Copyright (c) 2017 Microsoft
|
||||
Copyright (c) 2017-present, Facebook, Inc.
|
||||
Copyright (c) 2018-present, Facebook, Inc.
|
||||
|
||||
License: BSD 3-Clause License
|
||||
Please see above.
|
||||
@@ -0,0 +1,900 @@
|
||||
# Overview
|
||||
|
||||
Users can obtain PyTorch training models from Ascend ModelZoo, but the models do not support multi-server multi-device training. You need to modify the models based on the actual model code. This document describes how to quickly train a PyTorch model in Distributed Data Parallel (DDP) mode in multi-server multi-device scenario.
|
||||
|
||||
# Training Workflow
|
||||
|
||||
The process of training a PyTorch model in multi-server multi-device scenario includes environment preparation, model preparation, model modification, and training startup.
|
||||
|
||||
1. Environment Preparation
|
||||
|
||||
Prepare the software, hardware, and network environment for multi-server multi-device training, including setting up the development and operating environment, connecting the cluster network, setting the processor IP address, and setting the firewall.
|
||||
|
||||
2. Model Preparation
|
||||
|
||||
Prepare a PyTorch model, data loader, and optimizer for training. You can download them from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch) or prepare them by yourself.
|
||||
|
||||
3. Model Modification
|
||||
|
||||
Modify the basic model and add the code and environment variables required by DDP to enable the multi-server multi-device training.
|
||||
|
||||
4. Training Startup
|
||||
|
||||
Start model training in the multi-server multi-device scenario and view training logs.
|
||||
|
||||
|
||||
|
||||
# Quick Start
|
||||
|
||||
## Overview
|
||||
|
||||
The example presented in this document helps you quickly understand how a PyTorch model is trained in multi-server multi-device scenario. The example uses a custom model for training in two-computer eight-device scenario. The two computers are named AI Server0 and AI Server1. The eight Ascend 910 Processors on each computer are named device0 to device7.
|
||||
|
||||
## Preparing the Environment
|
||||
|
||||
At least two computers with Ascend 910 Processors installed are required, and the NPU firmware and driver are correctly installed on each computer.
|
||||
|
||||
1. Prepare the development and operating environment on each computer.
|
||||
|
||||
- Install the CANN development and operating environment. For details, see the *CANN Software Installation Guide*. Use CANN later than 5.0.3.
|
||||
|
||||
- Install the PyTorch that adapts to NPU. For details, see the *PyTorch Installation Guide*.
|
||||
|
||||
2. Prepare the network.
|
||||
|
||||
Set up the network by directly connecting switches or optical ports. For details, see the *Ascend Data Center Solution Networking Guide* at https://support.huawei.com/enterprise/en/doc/EDOC1100221995/229cc0e4.
|
||||
|
||||
In this example, two computers with eight devices are used for training, so optical ports are used for network connection.
|
||||
|
||||
3. Configure the device IP address.
|
||||
|
||||
Configure the device IP address on AI Server0.
|
||||
|
||||
```shell
|
||||
hccn_tool -i 0 -ip -s address 192.168.100.101 netmask 255.255.255.0
|
||||
hccn_tool -i 1 -ip -s address 192.168.101.101 netmask 255.255.255.0
|
||||
hccn_tool -i 2 -ip -s address 192.168.102.101 netmask 255.255.255.0
|
||||
hccn_tool -i 3 -ip -s address 192.168.103.101 netmask 255.255.255.0
|
||||
hccn_tool -i 4 -ip -s address 192.168.100.100 netmask 255.255.255.0
|
||||
hccn_tool -i 5 -ip -s address 192.168.101.100 netmask 255.255.255.0
|
||||
hccn_tool -i 6 -ip -s address 192.168.102.100 netmask 255.255.255.0
|
||||
hccn_tool -i 7 -ip -s address 192.168.103.100 netmask 255.255.255.0
|
||||
```
|
||||
|
||||
Configure the device IP address on AI Server1.
|
||||
|
||||
```shell
|
||||
hccn_tool -i 0 -ip -s address 192.168.100.111 netmask 255.255.255.0
|
||||
hccn_tool -i 1 -ip -s address 192.168.101.111 netmask 255.255.255.0
|
||||
hccn_tool -i 2 -ip -s address 192.168.102.111 netmask 255.255.255.0
|
||||
hccn_tool -i 3 -ip -s address 192.168.103.111 netmask 255.255.255.0
|
||||
hccn_tool -i 4 -ip -s address 192.168.100.110 netmask 255.255.255.0
|
||||
hccn_tool -i 5 -ip -s address 192.168.101.110 netmask 255.255.255.0
|
||||
hccn_tool -i 6 -ip -s address 192.168.102.110 netmask 255.255.255.0
|
||||
hccn_tool -i 7 -ip -s address 192.168.103.110 netmask 255.255.255.0
|
||||
```
|
||||
|
||||
4. Configure the firewall.
|
||||
|
||||
- Command for disabling the firewall on Ubuntu:
|
||||
|
||||
```shell
|
||||
ufw disable
|
||||
```
|
||||
```
|
||||
|
||||
- Command for disabling the firewall on Red Hat or CentOS 7:
|
||||
|
||||
```shell
|
||||
systemctl stop firewalld
|
||||
```
|
||||
|
||||
## Preparing a Model
|
||||
|
||||
This example creates a simple model for you to quickly understand multi-server multi-device training. You can also obtain the Ascend NPU-based PyTorch training model from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch).
|
||||
|
||||
1. Prepare a DDP model.
|
||||
|
||||
The following is an example of main.py for multi-server multi-device training.
|
||||
|
||||
```python
|
||||
import argparse
|
||||
import os
|
||||
import torch
|
||||
import torchvision
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import torch.distributed as dist
|
||||
from torch.nn.parallel import DistributedDataParallel as DDP
|
||||
|
||||
### 1. Perform basic operations. ###
|
||||
# Build a model.
|
||||
class ToyModel(nn.Module):
|
||||
def __init__(self):
|
||||
super(ToyModel, self).__init__()
|
||||
self.conv1 = nn.Conv2d(3, 6, 5)
|
||||
self.pool = nn.MaxPool2d(2, 2)
|
||||
self.conv2 = nn.Conv2d(6, 16, 5)
|
||||
self.fc1 = nn.Linear(16 * 5 * 5, 120)
|
||||
self.fc2 = nn.Linear(120, 84)
|
||||
self.fc3 = nn.Linear(84, 10)
|
||||
|
||||
def forward(self, x):
|
||||
x = self.pool(F.relu(self.conv1(x)))
|
||||
x = self.pool(F.relu(self.conv2(x)))
|
||||
x = x.view(-1, 16 * 5 * 5)
|
||||
x = F.relu(self.fc1(x))
|
||||
x = F.relu(self.fc2(x))
|
||||
x = self.fc3(x)
|
||||
return x
|
||||
|
||||
# Obtain a dataset.
|
||||
def get_dataset():
|
||||
transform = torchvision.transforms.Compose([
|
||||
torchvision.transforms.ToTensor(),
|
||||
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
|
||||
])
|
||||
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
|
||||
download=True, transform=transform)
|
||||
|
||||
train_sampler = torch.utils.data.distributed.DistributedSampler(my_trainset)
|
||||
trainloader = torch.utils.data.DataLoader(my_trainset,
|
||||
batch_size=16, num_workers=2, sampler=train_sampler)
|
||||
return trainloader
|
||||
|
||||
|
||||
### 2. Initialize the parameters, data, model, loss function, and optimizer. ####
|
||||
# Obtain local_rank and addr.
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--local_rank", default=-1, type=int)
|
||||
parser.add_argument("--addr", default='127.0.0.1', type=str, help='master addr')
|
||||
|
||||
FLAGS = parser.parse_args()
|
||||
local_rank = FLAGS.local_rank
|
||||
addr = FLAGS.addr
|
||||
|
||||
# Set the IP address and port of the master node.
|
||||
os.environ['MASTER_ADDR'] = addr
|
||||
os.environ['MASTER_PORT'] = '29501'
|
||||
|
||||
# Initialize the DDP backend.
|
||||
loc = 'npu:{}'.format(local_rank)
|
||||
torch.npu.set_device(loc)
|
||||
dist.init_process_group(backend='hccl') # HCCL is the backend of the NPU device.
|
||||
|
||||
|
||||
# Prepare data after DDP initialization.
|
||||
trainloader = get_dataset()
|
||||
|
||||
# Instantiate the model.
|
||||
model = ToyModel().to(loc)
|
||||
|
||||
# Load the model weight. The weight needs to be loaded only on the master node before the DDP model is built.
|
||||
ckpt_path = None
|
||||
if dist.get_rank() == 0 and ckpt_path is not None:
|
||||
model.load_state_dict(torch.load(ckpt_path))
|
||||
|
||||
# Build the DDP model.
|
||||
model = DDP(model, device_ids=[local_rank], output_device=local_rank)
|
||||
|
||||
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
|
||||
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
|
||||
|
||||
# Initialize the loss function.
|
||||
loss_func = nn.CrossEntropyLoss().to(loc)
|
||||
|
||||
### 3. Train the network.
|
||||
model.train()
|
||||
iterator = range(100)
|
||||
for epoch in iterator:
|
||||
trainloader.sampler.set_epoch(epoch)
|
||||
for data, label in trainloader:
|
||||
data, label = data.to(local_rank), label.to(local_rank)
|
||||
optimizer.zero_grad()
|
||||
prediction = model(data)
|
||||
loss = loss_func(prediction, label)
|
||||
loss.backward()
|
||||
print("loss = %0.3f \n" % loss)
|
||||
optimizer.step()
|
||||
|
||||
# 1. Similar to the DP mode, when you save a model, note that model.module instead of model is saved.
|
||||
# That is because the model actually refers to a DDP model, and the parameters are packaged by `model=DDP(model)`.
|
||||
# 2. You only need to save the model on process 0 once to avoid repeated saving.
|
||||
if dist.get_rank() == 0:
|
||||
torch.save(model.module.state_dict(), "%d.ckpt" % epoch)
|
||||
```
|
||||
|
||||
2. Ensure that the model is correct for training in the single-server multi-device scenario.
|
||||
|
||||
1. The Python third-party library is required if you install the model script yourself.
|
||||
|
||||
2. Configure NPU environment variables. For information about the **env_npu.sh** script, see the appendix.
|
||||
|
||||
```shell
|
||||
source env_npu.sh
|
||||
```
|
||||
|
||||
3. Execute **torch.distributed.launch** to run the following main.py command to train a model in single-server multi-device scenario.
|
||||
|
||||
```shell
|
||||
python -m torch.distributed.launch --nproc_per_node 8 main.py
|
||||
```
|
||||
|
||||
`--nproc_per_node` indicates the number of training cards.
|
||||
|
||||
After the command is run successfully, the model is trained on the eight NPUs of the device.
|
||||
|
||||
|
||||
|
||||
## Modifying the Model
|
||||
|
||||
The example provided in "Quick Start" is adapted to the multi-server multi-device training. You do not need to modify the script. For details about how to modify other models, see section "Multi-server Multi-device Training".
|
||||
|
||||
## Starting the Training
|
||||
|
||||
1. Upload main.py model script to any directory on AI Server0 and AI Server1.
|
||||
|
||||
2. Query the host IP addresses of the servers.
|
||||
|
||||
```shell
|
||||
hostname -I
|
||||
```
|
||||
|
||||
All IP addresses are displayed, and the first IP address is the host IP address of the current server.
|
||||
|
||||
For example, the host IP address of AI Server0 is **192.168.*xx*.22**, and that of AI Server1 is **192.168.*xx*.23**.
|
||||
|
||||
3. Use AI Server0 as the master node, and start the 2 x 8 cluster.
|
||||
|
||||
Startup commands for AI Server0:
|
||||
|
||||
```shell
|
||||
# Set environment variables. Obtain the env_npu.sh script content from the appendix.
|
||||
source env_npu.sh
|
||||
# Disable the trustlist of HCCL channel.
|
||||
export HCCL_WHITELIST_DISABLE=1
|
||||
# Initialize the IP address of the HCCL communication NIC, and set the IP address to the host IP address of the current server.
|
||||
export HCCL_IF_IP=192.168.xx.22
|
||||
#
|
||||
python3.7 -m torch.distributed.launch --nnodes=2 --node_rank=0 --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
|
||||
```
|
||||
|
||||
Startup commands for AI Server1:
|
||||
|
||||
```shell
|
||||
# Set environment variables. Obtain the env_npu.sh script content from the appendix.
|
||||
source env_npu.sh
|
||||
# Disable the trustlist of HCCL channel.
|
||||
export HCCL_WHITELIST_DISABLE=1
|
||||
# Initialize the IP address of the HCCL communication NIC, and set the IP address to the host IP address of the current server.
|
||||
export HCCL_IF_IP=192.168.xx.23
|
||||
|
||||
python3.7 -m torch.distributed.launch --nnodes=2 --node_rank=1 --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
|
||||
```
|
||||
|
||||
Parameter description:
|
||||
|
||||
--nnode: specifies the number of nodes used for distributed training scripts.
|
||||
|
||||
--node_rank: specifies the rank of the current node during multi-node distributed training.
|
||||
|
||||
--nproc_per_node: specifies the number of GPU-based training processes on the current node.
|
||||
|
||||
--master_addr: address of the master node (rank is 0). The value can be the IP address or the host name of node 0.
|
||||
|
||||
--master_port: specifies the port number used by the master node during distributed training.
|
||||
|
||||
--addr: input parameter of the main.py script, specifying the host IP address of the master node.
|
||||
|
||||
3. View the host logs.
|
||||
|
||||
Host logs are stored in the `~/ascend/log` directory. You can go to this directory to view the device logs of each host.
|
||||
|
||||
# Multi-server Multi-device Training
|
||||
|
||||
## Common Concepts and Parameters
|
||||
|
||||
Basic concepts for PyTorch distributed training
|
||||
|
||||
| Basic Concept | Description |
|
||||
| :-----------: | ------------------------------------------------------------ |
|
||||
| AI Server | Computer with an Ascend 910 Processors. Multiple computers are identified as AI Server +serial number, for example, AI Server0 and AI Server1. |
|
||||
| device | Ascend 910 Processors on the AI server. Multiple processors are represented as device 0, device 1, ..., and device 7. |
|
||||
| host | AI server host. |
|
||||
| master | Select one of multiple AI servers as the master node for data communication. |
|
||||
| group | Process group. By default, there is only one group. Use the default value. |
|
||||
| world size | Number of global parallel processes, which can be obtained by running **torch.distributed.get_world_size()**. The value is the same for different processes. |
|
||||
| rank | Sequence number of the current process, which is used for communication between processes. For example, for a 2 x 8 cluster, the **world size** is 16, and the rank in each process is [0, 1, 2, ..., 15]. |
|
||||
| local_rank | Sequence number of processes on each host, for example, there are processes 0-7 on each host. Generally, **local_rank** is used to set the GPU/NPU on which the current model runs. |
|
||||
|
||||
Parameters for executing **torch.distributed.launch** to start multi-device training
|
||||
|
||||
| Parameter | Description |
|
||||
| ------------------ | ------------------------------------------------------------ |
|
||||
| **nnodes** | Specifies the number of nodes used for distributed training scripts. |
|
||||
| **node_rank** | Specifies the rank of the current node during multi-node distributed training. |
|
||||
| **nproc_per_node** | Specifies the number of GPU-based training processes on the current node. You are advised to set this parameter to the number of GPUs on the current node. In this way, each process can independently control a GPU to achieve the highest efficiency. |
|
||||
| **master_addr** | Address of the master node (rank is 0). The value can be the IP address or the host name of node 0. For single-node multi-process training, set this parameter to **127.0.0.1**. |
|
||||
| **master_port**: | Specifies the port number used by the master node during distributed training. The port number must be different from the port numbers of other applications. |
|
||||
|
||||
## Multi-server Multi-device Training Process
|
||||
|
||||
### Preparing the Environment
|
||||
|
||||
At least two computers with Ascend 910 Processors installed are required, and the NPU firmware and driver are correctly installed on each server.
|
||||
|
||||
1. Prepare the development and operating environment on each computer.
|
||||
|
||||
- Install the CANN development and operating environment. For details, see the *CANN Software Installation Guide*. Use CANN later than 5.0.3.
|
||||
|
||||
- Install the PyTorch that adapts to NPU. For details, see the *PyTorch Installation Guide.*
|
||||
|
||||
2. Prepare the network.
|
||||
|
||||
Cluster training is completed by multiple computers (a maximum of 128) with Ascend 910 Processors installed. The computers need to work with switches to form a fully-connected active/standby network on the data plane. The 8 x *n*-device training is supported. Two computers can be directly connected through optical ports. For details, see the *Ascend Data Center Solution Networking Guide * at https://support.huawei.com/enterprise/en/doc/EDOC1100221995/229cc0e4.
|
||||
|
||||
3. Configure the device IP address.
|
||||
|
||||
Use hccn_tool to configure the device IP address. hccn_tool is provided by CANN.
|
||||
|
||||
```shell
|
||||
hccn_tool -i 0 -ip -s address 192.168.100.111 netmask 255.255.255.0
|
||||
```
|
||||
|
||||
Observe the following rules when configuring the device IP address:
|
||||
|
||||
1. On the AI servers, devices 0/4, 1/5, 2/6, and 3/7 must be in the same network segment. But devices 0, 1, 2, and 3 must be in different network segments, and devices 4, 5, 6, and 7 must be in different network segments.
|
||||
2. In the cluster scenario, the devices corresponding to each AI server must be in the same network segment. NICs 0 and 1 of AI Server0 and AI Server1 must be in the same network segment.
|
||||
3. Each IP address must be unique. IP addresses in the same network segment must be distinguished by the last eight bits.
|
||||
|
||||
Use hccn_tool to check whether the device IP address is correct.
|
||||
|
||||
- Query the IP address of each device.
|
||||
|
||||
```shell
|
||||
hccn_tool -i 0 -ip –g
|
||||
```
|
||||
|
||||
The IP addresses are displayed:
|
||||
|
||||
> ipaddr:192.168.100.101
|
||||
>
|
||||
> netmask:255.255.255.0
|
||||
|
||||
- Use hccn_tool to ensure that the devices of the two hosts are correctly connected by performing the test for eight times from device0 to devcie7.
|
||||
|
||||
```shell
|
||||
hccn_tool -i 0 -netdetect -s address xx.xx.xx.xx
|
||||
|
||||
hccn_tool -i 0 -net_health –g
|
||||
```
|
||||
|
||||
**-i**: device ID.
|
||||
|
||||
**-s address**: ***xx.xx.xx.xx*** is the IP address of device *i* on the other host.
|
||||
|
||||
If `success` is returned, the connection is successful.
|
||||
|
||||
4. Configure the firewall.
|
||||
|
||||
During HCCL communication, the firewall may intercept the communication port, causing communication timeout. Therefore, you need to disable the firewall on the server for PyTorch cluster training.
|
||||
|
||||
- Command for disabling the firewall on Ubuntu:
|
||||
|
||||
```shell
|
||||
ufw disable
|
||||
```
|
||||
|
||||
- Command for disabling the firewall on Red Hat or CentOS 7:
|
||||
|
||||
```shell
|
||||
systemctl stop firewalld
|
||||
```
|
||||
|
||||
### Preparing a Model
|
||||
|
||||
There are two methods for preparing a model.
|
||||
|
||||
- Download a PyTorch training model from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch).
|
||||
|
||||
The model obtained from the open source community supports single-server multi-device training. Modify the model based on the related parameters described in section "Modifying the Model".
|
||||
|
||||
- Manually build a PyTorch training model.
|
||||
|
||||
1. Prepare a PyTorch training model and data loader.
|
||||
|
||||
Prepare a PyTorch model:
|
||||
|
||||
```python
|
||||
class ToyModel(nn.Module):
|
||||
def __init__(self):
|
||||
...
|
||||
def forward(self,x):
|
||||
...
|
||||
```
|
||||
|
||||
Prepare data:
|
||||
|
||||
```python
|
||||
def get_dataset():
|
||||
transform = torchvision.transforms.Compose([
|
||||
torchvision.transforms.ToTensor(),
|
||||
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
|
||||
])
|
||||
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
|
||||
download=True, transform=transform)
|
||||
|
||||
trainloader = torch.utils.data.DataLoader(my_trainset,batch_size=16,)
|
||||
return trainloader
|
||||
|
||||
trainloader=get_dataset()
|
||||
```
|
||||
|
||||
2. Instantiate the model.
|
||||
|
||||
```python
|
||||
# Instantiate the model.
|
||||
model = ToyModel().to(loc)
|
||||
|
||||
# Load the model weight
|
||||
if ckpt_path is not None:
|
||||
model.load_state_dict(torch.load(ckpt_path))
|
||||
```
|
||||
|
||||
3. Prepare the loss function and optimizer.
|
||||
|
||||
```python
|
||||
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
|
||||
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
|
||||
|
||||
# Initialize the loss function.
|
||||
loss_func = nn.CrossEntropyLoss().to(loc)
|
||||
```
|
||||
|
||||
4. Train the model.
|
||||
|
||||
```python
|
||||
### 3. Train the network.
|
||||
model.train()
|
||||
iterator = range(100)
|
||||
for epoch in iterator:
|
||||
for data, label in trainloader:
|
||||
data, label = data.to(local_rank), label.to(local_rank)
|
||||
optimizer.zero_grad()
|
||||
prediction = model(data)
|
||||
loss = loss_func(prediction, label)
|
||||
loss.backward()
|
||||
print("loss = %0.3f \n" % loss)
|
||||
optimizer.step()
|
||||
|
||||
torch.save(model.state_dict(), "%d.ckpt" % epoch)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Modifying the Model
|
||||
|
||||
Modify the IP address and port of the master node, initialize the **distributed ** function, model DDP, data DDP, and optimizer, and modify the DDP model training method based on the initial model code.
|
||||
|
||||
1. Set the IP address and port for the master node. In the NPU distributed training, HCCL is used for communication, while in PyTorch, the HCCL communication mechanism that is detected by automatic topology is used. That is, **RANK_TABLE_FLIE** is not required, but the communication depends on the NIC on the host side. Therefore, you need to set environment variables in the code to set the communication NIC.
|
||||
|
||||
```python
|
||||
os.environ['MASTER_ADDR'] = xxx.xxx.xxx.xxx
|
||||
os.environ['MASTER_PORT'] = 'xxx'
|
||||
```
|
||||
|
||||
**MASTER_ADDR**: Set this parameter to the IP address of the master node in the cluster. (Select any host as the master node.)
|
||||
|
||||
**MASTER_PORT**: Set this parameter to the idle port of the master node.
|
||||
|
||||
In the model code, the IP address and port number of the master node are generally presented as transferred parameters. In some open-source code, the IP address and port number may be presented as **127.0.0.1**. In this case, you need to modify them.
|
||||
|
||||
The preceding variables must be declared before **torch.distributed.init_process_group()** is invoked.
|
||||
|
||||
2. Initialize **distributed**.
|
||||
|
||||
In PyTorch, `dist.init_process_group(backend='hccl', world_size=world_size, rank=rank)` is used to initialize thread groups. The parameters are described as follows:
|
||||
|
||||
`backend`: communication protocol used for distributed training. Only hccl can be used on the NPU.
|
||||
|
||||
`world_size`: total number of devices used for training.
|
||||
|
||||
`rank`: rank ID of the currently initialized device, that is, the global logical ID.
|
||||
|
||||
There are two methods to start multi-device training:
|
||||
|
||||
- **torch.distributed.launch**:
|
||||
|
||||
```python
|
||||
import torch.distributed as dist
|
||||
|
||||
dist.init_process_group(backend='hccl') # HCCL is the backend of the NPU device.
|
||||
```
|
||||
|
||||
- **mp.spawn**:
|
||||
|
||||
```python
|
||||
import torch.distributed as dist
|
||||
|
||||
def main_worker(pid_idx, device_nums_per_node, args):
|
||||
args.distributed_rank = args.rank * device_nums_per_node + pid_idx
|
||||
dist.init_process_group(backend=args.dist_backend, world_size=args.distributed_world_size, rank=args.distributed_rank)
|
||||
```
|
||||
|
||||
In the preceding commands:
|
||||
|
||||
`pid_idx`: device ID.
|
||||
|
||||
`device_nums_per_node`: number of devices on each AI server.
|
||||
|
||||
3. Initialize the model DDP.
|
||||
|
||||
```python
|
||||
# Instantiate the model.
|
||||
model = ToyModel().to(loc)
|
||||
|
||||
# Load the model weight. It needs to be loaded only on the master node before the DDP model is built.
|
||||
if dist.get_rank() == 0 and ckpt_path is not None:
|
||||
model.load_state_dict(torch.load(ckpt_path))
|
||||
|
||||
# Build the DDP model.
|
||||
model = DDP(model, device_ids=[local_rank], output_device=local_rank)
|
||||
```
|
||||
|
||||
4. Initialize the data DDP.
|
||||
|
||||
```python
|
||||
def get_dataset():
|
||||
transform = torchvision.transforms.Compose([
|
||||
torchvision.transforms.ToTensor(),
|
||||
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
|
||||
])
|
||||
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
|
||||
download=True, transform=transform)
|
||||
|
||||
train_sampler = torch.utils.data.distributed.DistributedSampler(my_trainset)
|
||||
trainloader = torch.utils.data.DataLoader(my_trainset,
|
||||
batch_size=16, num_workers=2, sampler=train_sampler)
|
||||
return trainloader
|
||||
|
||||
trainloader = get_dataset()
|
||||
```
|
||||
|
||||
5. Initialize the loss function and optimizer.
|
||||
|
||||
```python
|
||||
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
|
||||
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
|
||||
|
||||
# Initialize the loss function.
|
||||
loss_func = nn.CrossEntropyLoss().to(loc)
|
||||
```
|
||||
|
||||
6. Train the DDP model.
|
||||
|
||||
```python
|
||||
model.train()
|
||||
iterator = range(100)
|
||||
for epoch in iterator:
|
||||
# Set epoch.
|
||||
trainloader.sampler.set_epoch(epoch)
|
||||
|
||||
for data, label in trainloader:
|
||||
data, label = data.to(local_rank), label.to(local_rank)
|
||||
optimizer.zero_grad()
|
||||
prediction = model(data)
|
||||
loss = loss_func(prediction, label)
|
||||
loss.backward()
|
||||
print("loss = %0.3f \n" % loss)
|
||||
optimizer.step()
|
||||
|
||||
# 1. Similar to the DP mode, when you save a model, note that model.module instead of model is saved.
|
||||
# That is because the model actually refers to a DDP model, and the parameters are packaged by `model=DDP(model)`.
|
||||
# 2. You only need to save the model on process 0 once to avoid repeated saving.
|
||||
if dist.get_rank() == 0:
|
||||
torch.save(model.module.state_dict(), "%d.ckpt" % epoch)
|
||||
```
|
||||
|
||||
### Start the Training
|
||||
|
||||
The training can be started manually or using the shell script.
|
||||
|
||||
- Start the training manually using **torch.distributed.launch**.
|
||||
|
||||
1. Configure NPU environment variables. For details, see the **env_npu.sh** script in the appendix.
|
||||
|
||||
2. Add environment variables. For multi-server training, add the `HCCL_WHITELIST_DISABLE` and `HCCL_IF_IP` environment variables.
|
||||
|
||||
- **HCCL_WHITELIST_DISABLE**: HCCL channel trustlist. The value **1** indicates that the trustlist is disabled.
|
||||
- **HCCL_IF_IP**: initialized IP address of the HCCL communication NIC. Set it to the IP address of the host NIC IP of the current server.
|
||||
|
||||
3. Upload the modified model script to each AI server.
|
||||
|
||||
4. Install the required Python library on each AI server.
|
||||
|
||||
5. Select an AI server as the master node and query the IP address of each AI server.
|
||||
|
||||
6. Run the following commands on each AI server:
|
||||
|
||||
```
|
||||
python3 -m torch.distributed.launch --nnodes=${nnodes} --node_rank=i --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
|
||||
```
|
||||
|
||||
In the preceding commands:
|
||||
|
||||
**--nnodes**: number of AI servers used for distributed training scripts.
|
||||
|
||||
**--node_rank**: AI server ID.
|
||||
|
||||
**--nproc_per_node**: number of devices of each AI server.
|
||||
|
||||
**--master_addr**: IP address of the AI server that functions as the master node.
|
||||
|
||||
**--master_port**: port number of the AI server that functions as the master node.
|
||||
|
||||
**main.py**: Change it to the name of the startup script.
|
||||
|
||||
**--addr**: indicates the IP address of the master node, which is a parameter transferred to the startup script.
|
||||
|
||||
- Start the training using Open MPI.
|
||||
|
||||
1. Install the PI open-source library.
|
||||
|
||||
In the multi-server multi-device scenario, distributed training deployment depends on the Open MPI open-source library, which must be installed on each server that participates in model training. Currently, Open MPI 4.0.1, 4.0.2, or 4.0.3 is required.
|
||||
Run the **mpirun --version** command to check whether Open MPI has been installed. If `mpirun (Open MPI) 4.0.2 Report bugs to http://www.open-mpi.org/community/help/` is returned, Open MPI has been installed. If it has been installed and its version is 4.0.1, 4.0.2, or 4.0.3, you do not need to install it again.
|
||||
|
||||
Otherwise, perform the following steps to install it
|
||||
|
||||
1. Visit the following link to download the Open MPI software package, for example, openmpi-4.0.2.tar.bz2.
|
||||
https://www.open-mpi.org/software/ompi/v4.0/
|
||||
|
||||
2. Log in to the installation environment as the root user.
|
||||
|
||||
3. Upload the downloaded Open MPI software package to a directory in the installation environment.
|
||||
|
||||
4. Go to the directory and run the following command to decompress the software package:
|
||||
|
||||
```shell
|
||||
tar -jxvf openmpi-4.0.2.tar.bz2
|
||||
```
|
||||
|
||||
5. Go to the directory generated after the decompression, and run the following commands to configure, compile, and install Open MPI:
|
||||
|
||||
```shell
|
||||
./configure --prefix=/usr/local/mpirun4.0.2
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
The **--prefix** parameter specifies the Open MPI installation path. Change it based on the site requirements.
|
||||
|
||||
6. Run the **vi ~/.bashrc** command to open the **.bashrc** file, and add the following environment variables to the end of the file:
|
||||
|
||||
```shell
|
||||
export OPENMPI=/usr/local/mpirun4.0.2
|
||||
export LD_LIBRARY_PATH=$OPENMPI/lib
|
||||
export PATH=$OPENMPI/bin:$PATH
|
||||
```
|
||||
|
||||
In the environment variables, **/usr/local/mpirun4.0.2** indicates the Open MPI installation path. Change it based on the site requirements.
|
||||
Run the **:wq!** command to save the file and exit.
|
||||
|
||||
7. Make the configuration take effect.
|
||||
|
||||
```
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
8. After the installation is complete, run the following command to check the installation version. If the required version information is displayed, the installation is successful.
|
||||
|
||||
```
|
||||
mpirun --version
|
||||
```
|
||||
|
||||
2. Configure SSH password-free login for the AI servers.
|
||||
|
||||
If Open MPI is used for distributed training deployment in the multi-server multi-device scenario, you need to configure SSH password-free login between every two servers to ensure that the servers can communicate with each other. The procedure is as follows:
|
||||
|
||||
1. Log in to each server as the root user.
|
||||
|
||||
2. Configure the reliability among hosts in the cluster.
|
||||
|
||||
Open the **/etc/ssh/ssh_config** file and add the following fields to the end of the file:
|
||||
|
||||
```
|
||||
StrictHostKeyChecking no
|
||||
UserKnownHostsFile /dev/null
|
||||
```
|
||||
|
||||
3. Open the **/etc/hosts** file on each server and add the corresponding IP address and host name of the server to the first line of the file. If the file already contains the IP address and host name, skip this step. The following is an example of the content to be added:
|
||||
|
||||
```
|
||||
10.90.140.199 ubuntu
|
||||
```
|
||||
|
||||
In the preceding content, **10.90.140.199** is the IP address of the server, and **ubuntu** is the host name.
|
||||
|
||||
4. Run the following commands on the first server to generate a public key (Assume that the IP address of the first server is **10.90.140.199**.):
|
||||
|
||||
```
|
||||
cd ~/.ssh/ # If the directory does not exist, run the ssh localhost command first.
|
||||
ssh-keygen -t rsa # After the key is generated, a message is displayed. Press Enter for three consecutive times.
|
||||
mv id_rsa.pub authorized_keys # Renames the generated key id_rsa.pub to authorized_keys.
|
||||
```
|
||||
|
||||
5. Generate a key on each of the other servers, and copy the keys to the **authorized_keys** file on the first server.
|
||||
|
||||
1. Run the following commands on each of the other servers to generate a key:
|
||||
|
||||
cd ~/.ssh/
|
||||
ssh-keygen -t rsa
|
||||
|
||||
2. Download the key file **id_rsa.pub** generated on each server to the local host and copy the key in the file.
|
||||
|
||||
3. On the first server, run the following command to open the authorized_keys file and copy the keys of each of other servers to the end of the public key of the first server.
|
||||
|
||||
```
|
||||
vi ~/.ssh/authorized_keys
|
||||
```
|
||||
|
||||
Run the **:wq!** command to save the file.
|
||||
|
||||
6. Run the following commands on each of the other servers to copy the public key of the first server to each of the other servers:
|
||||
|
||||
cd ~/.ssh/
|
||||
scp root@10.90.140.199:~/.ssh/authorized_keys ./
|
||||
|
||||
7. Run the following command on each server to test password-free login:
|
||||
|
||||
```
|
||||
ssh User name@IP address
|
||||
```
|
||||
|
||||
For example, run the **ssh root@10.90.140.231** command to log in to the server whose IP address is 10.90.140.231 from the first server whose IP address is 10.90.140.199 without a password.
|
||||
|
||||
If information similar to the following is displayed, the login without a password is successful.
|
||||
|
||||
```
|
||||
Linux ubuntu 4.19.28 #1 SMP Tue Jun 23 19:05:23 EDT 2020 x86_64
|
||||
|
||||
The programs included with the ubuntu GNU/Linux system are free software;
|
||||
the exact distribution terms for each program are described in the
|
||||
individual files in /usr/share/doc/*/copyright.
|
||||
|
||||
ubuntu GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
permitted by applicable law.
|
||||
Last login: Tue Sep 15 14:37:21 2020 from 10.254.88.75
|
||||
```
|
||||
|
||||
You can run the **exit** command to log out of the server. If information similar to the following is displayed, the logout is successful.
|
||||
|
||||
```
|
||||
logout
|
||||
Connection to 10.90.140.231 closed.
|
||||
```
|
||||
3. Use Open MPI to start model training.
|
||||
|
||||
1. Compile a startup script for each AI server, for example, train.sh, and move the startup script to the same path of the corresponding AI server.
|
||||
|
||||
```
|
||||
# Configure NPU environment variables. For information about the env_npu.sh script, see the appendix.
|
||||
source env_npu.sh
|
||||
#Disable the trustlist of HCCL channel.
|
||||
export HCCL_WHITELIST_DISABLE=1
|
||||
# Initialize the IP address of the HCCL communication NIC , and set the IP address to the host IP address of the current server.
|
||||
export HCCL_IF_IP=xxx.xxx.xx.xxx
|
||||
python3 -m torch.distributed.launch --nnodes=${nnodes} --node_rank=i --nproc_per_node 8 --master_addr xxx.xxx.xx.xxx --master_port 29501 main.py --addr xxx.xxx.xx.xxx
|
||||
```
|
||||
|
||||
For details about the script parameters, see section "Start the training manually using **torch.distributed.launch**".
|
||||
|
||||
2. Compile the startup script.
|
||||
|
||||
```
|
||||
# Configuring the mpirun environment variables.
|
||||
export PATH=$PATH:/usr/local/mpirun4.0.2/bin
|
||||
# Run the mpirun tool.
|
||||
mpirun -H xxx.xxx.xxx.xxx:1,xxx.xxx.xxx.xxx:1 \
|
||||
--bind-to none -map-by slot \
|
||||
--mca btl_tcp_if_exclude lo,docker0,endvnic\
|
||||
--allow-run-as-root \
|
||||
--prefix /usr/local/mpirun4.0.2/ \
|
||||
./train.sh
|
||||
```
|
||||
|
||||
In the preceding command:
|
||||
|
||||
**-H**: IP address of each AI server and the number of started processes.
|
||||
|
||||
**--bind-to**: process-binding policy.
|
||||
|
||||
**--mca**: MCA parameter in a specific context. **arg0** is the parameter name, and **arg1** is the parameter value.
|
||||
|
||||
**--allow-run-as-root**: The root user is allowed to run this script.
|
||||
|
||||
**--prefix**: path of mpirun4.0.2.
|
||||
|
||||
**./train.sh**: path of the startup script of each AI server.
|
||||
|
||||
4. View the log information after the training succeeds.
|
||||
|
||||
|
||||
|
||||
Host logs are stored in the `~/ascend/log` directory. You can go to this directory to view the device logs of each host.
|
||||
|
||||
# Appendix
|
||||
|
||||
The following shows the NPU environment variable configuration script **env_npu.sh**, which can be used to configure the operating and development environment variables.
|
||||
|
||||
```shell
|
||||
#!/bin/bash
|
||||
export install_path=/usr/local/Ascend
|
||||
|
||||
if [ -d ${install_path}/toolkit ]; then
|
||||
export LD_LIBRARY_PATH=/usr/include/hdf5/lib/:/usr/local/:/usr/local/lib/:/usr/lib/:${install_path}/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons:${path_lib}:${LD_LIBRARY_PATH}
|
||||
export PATH=${install_path}/fwkacllib/ccec_compiler/bin:${install_path}/fwkacllib/bin:$PATH
|
||||
export PYTHONPATH=${install_path}/fwkacllib/python/site-packages:${install_path}/tfplugin/python/site-packages:${install_path}/toolkit/python/site-packages:$PYTHONPATH
|
||||
export PYTHONPATH=/usr/local/python3.7.5/lib/python3.7/site-packages:$PYTHONPATH
|
||||
export ASCEND_OPP_PATH=${install_path}/opp
|
||||
else
|
||||
if [ -d ${install_path}/nnae/latest ];then
|
||||
exportLD_LIBRARY_PATH=/usr/local/:/usr/local/python3.7.5/lib/:/usr/local/openblas/lib:/usr/local/lib/:/usr/lib64/:/usr/lib/:${install_path}/nnae/latest/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons/:/usr/lib/aarch64_64-linux-gnu:$LD_LIBRARY_PATH
|
||||
export PATH=$PATH:${install_path}/nnae/latest/fwkacllib/ccec_compiler/bin/:${install_path}/nnae/latest/toolkit/tools/ide_daemon/bin/
|
||||
export ASCEND_OPP_PATH=${install_path}/nnae/latest/opp/
|
||||
export OPTION_EXEC_EXTERN_PLUGIN_PATH=${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
|
||||
export PYTHONPATH=${install_path}/nnae/latest/fwkacllib/python/site-packages/:${install_path}/nnae/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:${install_path}/nnae/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
|
||||
export ASCEND_AICPU_PATH=${install_path}/nnae/latest
|
||||
else
|
||||
export LD_LIBRARY_PATH=/usr/local/:/usr/local/lib/:/usr/lib64/:/usr/lib/:/usr/local/python3.7.5/lib/:/usr/local/openblas/lib:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons/:/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH
|
||||
export PATH=$PATH:${install_path}/ascend-toolkit/latest/fwkacllib/ccec_compiler/bin/:${install_path}/ascend-toolkit/latest/toolkit/tools/ide_daemon/bin/
|
||||
export ASCEND_OPP_PATH=${install_path}/ascend-toolkit/latest/opp/
|
||||
export OPTION_EXEC_EXTERN_PLUGIN_PATH=${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
|
||||
export PYTHONPATH=${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/:${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
|
||||
export ASCEND_AICPU_PATH=${install_path}/ascend-toolkit/latest
|
||||
fi
|
||||
fi
|
||||
|
||||
#Output host logs to the serial port. 0: disable; 1: enable.
|
||||
export ASCEND_SLOG_PRINT_TO_STDOUT=0
|
||||
#Set the default log level. 0: debug; 1: info; 2: warning; 3: error.
|
||||
export ASCEND_GLOBAL_LOG_LEVEL=3
|
||||
#Enable or disable the event log. 0: disable; 1: enable.
|
||||
export ASCEND_GLOBAL_EVENT_ENABLE=0
|
||||
#Enable or disable taskque. 0: disable; 1: enable.
|
||||
export TASK_QUEUE_ENABLE=1
|
||||
#Enable or disable the HCCL trustlist. 1: disable; 0: enable.
|
||||
export HCCL_WHITELIST_DISABLE=1
|
||||
|
||||
#Set the device-side log to error.
|
||||
${install_path}/driver/tools/msnpureport -g error -d 0
|
||||
${install_path}/driver/tools/msnpureport -g error -d 1
|
||||
${install_path}/driver/tools/msnpureport -g error -d 2
|
||||
${install_path}/driver/tools/msnpureport -g error -d 3
|
||||
${install_path}/driver/tools/msnpureport -g error -d 4
|
||||
${install_path}/driver/tools/msnpureport -g error -d 5
|
||||
${install_path}/driver/tools/msnpureport -g error -d 6
|
||||
${install_path}/driver/tools/msnpureport -g error -d 7
|
||||
#Disable the event log on the device side.
|
||||
${install_path}/driver/tools/msnpureport -e disable
|
||||
|
||||
path_lib=$(python3.7 -c """
|
||||
import sys
|
||||
import re
|
||||
result=''
|
||||
for index in range(len(sys.path)):
|
||||
match_sit = re.search('-packages', sys.path[index])
|
||||
if match_sit is not None:
|
||||
match_lib = re.search('lib', sys.path[index])
|
||||
|
||||
if match_lib is not None:
|
||||
end=match_lib.span()[1]
|
||||
result += sys.path[index][0:end] + ':'
|
||||
|
||||
result+=sys.path[index] + '/torch/lib:'
|
||||
print(result)"""
|
||||
)
|
||||
|
||||
echo ${path_lib}
|
||||
|
||||
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib/:${path_lib}:$LD_LIBRARY_PATH
|
||||
```
|
||||
@@ -0,0 +1,564 @@
|
||||
# PyTorch Installation Guide
|
||||
- [Overview](#overviewmd)
|
||||
- [Manual Build and Installation](#manual-build-and-installationmd)
|
||||
- [Prerequisites](#prerequisitesmd)
|
||||
- [Installing the PyTorch Framework](#installing-the-pytorch-frameworkmd)
|
||||
- [Configuring Environment Variables](#configuring-environment-variablesmd)
|
||||
- [Installing the Mixed Precision Module](#installing-the-mixed-precision-modulemd)
|
||||
- [References](#referencesmd)
|
||||
- [Installing CMake](#installing-cmakemd)
|
||||
- [How Do I Install GCC 7.3.0?](#how-do-i-install-gcc-7-3-0md)
|
||||
- [What to Do If "torch 1.5.0xxxx" and "torchvision" Do Not Match When torch-\*.whl Is Installed?](#what-to-do-if-torch-1-5-0xxxx-and-torchvision-do-not-match-when-torch--whl-is-installedmd)
|
||||
<h2 id="overviewmd">Overview</h2>
|
||||
|
||||
When setting up the environment for PyTorch model development and running, you can manually build and install the modules adapted to the PyTorch framework on a server.
|
||||
|
||||
**Figure 1** Environment setup process<a name="en-us_topic_0000001119176876_fig1938918396117"></a>
|
||||
|
||||
|
||||

|
||||
|
||||
<h2 id="manual-build-and-installationmd">Manual Build and Installation</h2>
|
||||
|
||||
- **[Prerequisites](#prerequisitesmd)**
|
||||
|
||||
- **[Installing the PyTorch Framework](#installing-the-pytorch-frameworkmd)**
|
||||
|
||||
- **[Configuring Environment Variables](#configuring-environment-variablesmd)**
|
||||
|
||||
- **[Installing the Mixed Precision Module](#installing-the-mixed-precision-modulemd)**
|
||||
|
||||
|
||||
<h3 id="prerequisitesmd">Prerequisites</h3>
|
||||
|
||||
#### Prerequisites<a name="en-us_topic_0000001105856382_en-us_topic_0275872734_section108914373254"></a>
|
||||
|
||||
- The development or operating environment of CANN has been installed. For details, see the _CANN Software Installation Guide_.
|
||||
- CMake 3.12.0 or later has been installed. For details about how to install CMake, see [Installing CMake](#installing-cmakemd).
|
||||
- GCC 7.3.0 or later has been installed. For details about how to install and use GCC 7.3.0, see [How Do I Install GCC 7.3.0?](#how-do-i-install-gcc-7-3-0md).
|
||||
- Python 3.7.5, 3.8, or 3.9 has been installed.
|
||||
- Note that PyTorch 1.5 does not support Python 3.9 build and installation. Only Torch 1.8.1 supports Python 3.9 build and installation.
|
||||
- The Patch and Git tools have been installed in the environment. To install the tools for Ubuntu and CentOS, run the following commands:
|
||||
- Ubuntu
|
||||
|
||||
```
|
||||
apt-get install patch
|
||||
apt-get install git
|
||||
```
|
||||
|
||||
- CentOS
|
||||
|
||||
```
|
||||
yum install patch
|
||||
yum install git
|
||||
```
|
||||
|
||||
|
||||
|
||||
<h3 id="installing-the-pytorch-frameworkmd">Installing the PyTorch Framework</h3>
|
||||
|
||||
#### Installation Process<a name="en-us_topic_0000001152776301_section1611810384557"></a>
|
||||
|
||||
1. Log in to the server as the **root** user or a non-root user.
|
||||
2. Run the following commands in sequence to install the PyTorch dependencies.
|
||||
|
||||
If you install Python and its dependencies as a non-root user, add **--user** at the end of each command in this step. Example command: **pip3.7 install pyyaml --user**.
|
||||
|
||||
```
|
||||
pip3 install pyyaml
|
||||
pip3 install wheel
|
||||
```
|
||||
|
||||
3. Obtain the PyTorch source code.
|
||||
|
||||
1. Run the following command to obtain the PyTorch source code adapted to Ascend AI Processors and switch to the required branch:
|
||||
|
||||
```
|
||||
git clone https://gitee.com/ascend/pytorch.git
|
||||
# By default, the masterf branch is used. If other branches are required, run the git checkout command to switch to that branch.
|
||||
cd pytorch
|
||||
git checkout -b 2.0.4.tr5 remotes/origin/2.0.4.tr5
|
||||
|
||||
```
|
||||
|
||||
The directory structure of the downloaded source code is as follows:
|
||||
|
||||
```
|
||||
├── patch # Directory of the patch adapted to Ascend AI Processors
|
||||
│ ├── pytorch1.5.0_npu.patch # Patch for PyTorch 1.5.0
|
||||
│ └── pytorch1.8.1_npu.patch # Patch for PyTorch 1.8.1
|
||||
├── pytorch1.5.0 # Source code and test directory for PyTorch 1.5.0
|
||||
│ ├── access_control_test.py
|
||||
│ ├── src # Source code directory
|
||||
│ └── test # Directory for storing test cases
|
||||
├── pytorch1.8.1 # Source code and test directory for PyTorch 1.8.1
|
||||
│ ├── access_control_test.py
|
||||
│ ├── src # Source code directory
|
||||
│ └── test # Directory for storing test cases
|
||||
└── scripts # Build and create a directory.
|
||||
```
|
||||
|
||||
2. Obtain the native PyTorch source code from the root directory **/pytorch** of the current repository.
|
||||
- If PyTorch 1.5.0 is installed, run the following command:
|
||||
|
||||
```
|
||||
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
```
|
||||
|
||||
- If PyTorch 1.8.1 is installed, run the following command:
|
||||
|
||||
```
|
||||
git clone -b v1.8.1 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
```
|
||||
|
||||
3. Go to the native PyTorch code directory **pytorch** and obtain the PyTorch passive dependency code.
|
||||
|
||||
```
|
||||
cd pytorch
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
> **NOTE:**
|
||||
>Due to network fluctuation, it may take a long time to obtain the source code. If no error is reported after the download is complete, the PyTorch and third-party code on which PyTorch depends are generated.
|
||||
|
||||
4. Generate the PyTorch installation package adapted to Ascend AI Processors.
|
||||
1. Go to the **pytorch/scripts** directory and run the conversion script to generate full code adapted to Ascend AI Processors.
|
||||
|
||||
```
|
||||
cd ../scripts
|
||||
# If PyTorch 1.5.0 is installed:
|
||||
bash gen.sh
|
||||
# If PyTorch 1.8.1 is installed:
|
||||
bash gen.sh -v 1.8.1
|
||||
```
|
||||
|
||||
The full code adapted to Ascend AI Processors is generated in the **pytorch/pytorch** directory.
|
||||
|
||||
2. Go to the **pytorch/pytorch/** directory and install the dependency library.
|
||||
|
||||
```
|
||||
cd ../pytorch
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
3. Build and generate the binary installation package of PyTorch.
|
||||
|
||||
```
|
||||
bash build.sh --python=3.7
|
||||
or
|
||||
bash build.sh --python=3.8
|
||||
or
|
||||
bash build.sh --python=3.9 # PyTorch 1.5 does not support build and installation using Python 3.9.
|
||||
|
||||
```
|
||||
|
||||
Specify the Python version in the environment for build. The generated binary package is stored in the current dist directory **pytorch/pytorch/dist**.
|
||||
|
||||
5. <a name="en-us_topic_0000001152776301_li49671667141"></a>Install PyTorch.
|
||||
|
||||
Go to the **pytorch/pytorch/dist** directory and run the following command to install PyTorch:
|
||||
|
||||
```
|
||||
cd dist
|
||||
pip3 install --upgrade torch-1.5.0+ascend.post3-cp37-cp37m-linux_{arch}.whl
|
||||
```
|
||||
|
||||
_\{**arch\}**_ indicates the architecture information. The value can be **aarch64** or **x86\_64**.
|
||||
|
||||
> **NOTE:**
|
||||
>To upgrade PyTorch in the environment, uninstall the PyTorch software package installed in the environment and then perform [Step 5 Install PyTorch](#en-us_topic_0000001152776301_li49671667141). Run the following command to check whether PyTorch has been installed:
|
||||
>**pip3 list | grep torch**
|
||||
|
||||
|
||||
<h3 id="configuring-environment-variablesmd">Configuring Environment Variables</h3>
|
||||
|
||||
After the software packages are installed, configure environment variables to use Ascend PyTorch. For details about the environment variables, see [Table 1](#en-us_topic_0000001152616261_table42017516135).
|
||||
|
||||
1. Configure the operating environment variables by running the following command in the **root** directory of the PyTorch source code adapted to Ascend AI Processors:
|
||||
|
||||
```
|
||||
cd ../
|
||||
source env.sh
|
||||
```
|
||||
|
||||
2. Select a proper HCCL initialization mode based on the actual scenario and configure the corresponding environment variables.
|
||||
|
||||
```
|
||||
# Scenario 1: Single-node scenario
|
||||
export HCCL_WHITELIST_DISABLE=1 # Disable the HCCL trustlist.
|
||||
# Scenario 2: Multi-node scenario
|
||||
export HCCL_WHITELIST_DISABLE=1 # Disable the HCCL trustlist.
|
||||
export HCCL_IF_IP="1.1.1.1" # Replace 1.1.1.1 with the actual NIC IP address of the host. Ensure that the NIC IP addresses in use can communicate with each other in the cluster.
|
||||
```
|
||||
|
||||
3. \(Optional\) Configure function or performance environment variables in the NPU scenario. The variables are disabled by default.
|
||||
|
||||
```
|
||||
export DYNAMIC_COMPILE_ENABLE=1 # (Optional) Dynamic shape feature, which is used when the shape changes. To enable this function, set the value to 1. (PyTorch 1.8.1 does not support this environment variable.)
|
||||
export COMBINED_ENABLE=1 # (Optional) Optimizes the scenario where two inconsecutive operators are combined. To enable this function, set the value to 1.
|
||||
export TRI_COMBINED_ENABLE=1 # (Optional) Optimizes the scenario where three inconsecutive operators are combined. To enable this function, set the value to 1.
|
||||
export ACL_DUMP_DATA=1 # (Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to 1.
|
||||
export DYNAMIC_OP="ADD#MUL" # (Optional) Operator implementation. The performance of the ADD and MUL operators varies depending on the scenarios.
|
||||
```
|
||||
|
||||
4. \(Optional\) If the system is openEuler or its inherited OS, such as UOS, run the following command to cancel CPU core binding.
|
||||
|
||||
```
|
||||
# unset GOMP_CPU_AFFINITY
|
||||
```
|
||||
|
||||
|
||||
**Table 1** Description of environment variables
|
||||
|
||||
<a name="en-us_topic_0000001152616261_table42017516135"></a>
|
||||
<table><thead align="left"><tr id="en-us_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="en-us_topic_0000001152616261_p51981251161315"><a name="en-us_topic_0000001152616261_p51981251161315"></a><a name="en-us_topic_0000001152616261_p51981251161315"></a>Environment Variable</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="en-us_topic_0000001152616261_p9198135114133"><a name="en-us_topic_0000001152616261_p9198135114133"></a><a name="en-us_topic_0000001152616261_p9198135114133"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="en-us_topic_0000001152616261_row6882121917329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p688241953218"><a name="en-us_topic_0000001152616261_p688241953218"></a><a name="en-us_topic_0000001152616261_p688241953218"></a>LD_LIBRARY_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p1888291915322"><a name="en-us_topic_0000001152616261_p1888291915322"></a><a name="en-us_topic_0000001152616261_p1888291915322"></a>Dynamic library search path. Set this variable based on the preceding example.</p>
|
||||
<p id="p1292181892120"><a name="p1292181892120"></a><a name="p1292181892120"></a>If you need to upgrade GCC in OSs such as CentOS, Debian, and BC-Linux, add <strong id="b6163826603"><a name="b6163826603"></a><a name="b6163826603"></a><em id="i161631926505"><a name="i161631926505"></a><a name="i161631926505"></a>${install_path}</em>/lib64</strong> to the <span class="parmname" id="parmname161637265015"><a name="parmname161637265015"></a><a name="parmname161637265015"></a><b>LD_LIBRARY_PATH</b></span> variable of the dynamic library search path. Replace <em id="i01649261704"><a name="i01649261704"></a><a name="i01649261704"></a><strong id="b1216317261109"><a name="b1216317261109"></a><a name="b1216317261109"></a>{install_path}</strong></em> with the GCC installation path. For details, see <a href="#how-do-i-install-gcc-7-3-0md#en-us_topic_0000001135347812_en-us_topic_0000001173199577_en-us_topic_0000001172534867_en-us_topic_0276688294_li9745165315131">5</a>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row16194175523010"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p16195185523019"><a name="en-us_topic_0000001152616261_p16195185523019"></a><a name="en-us_topic_0000001152616261_p16195185523019"></a>PYTHONPATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p19637083322"><a name="en-us_topic_0000001152616261_p19637083322"></a><a name="en-us_topic_0000001152616261_p19637083322"></a>Python search path. Set this variable based on the preceding example.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row2954102119329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p195452113218"><a name="en-us_topic_0000001152616261_p195452113218"></a><a name="en-us_topic_0000001152616261_p195452113218"></a>PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p964914893211"><a name="en-us_topic_0000001152616261_p964914893211"></a><a name="en-us_topic_0000001152616261_p964914893211"></a>Executable program search path. Set this variable based on the preceding example.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row58592816294"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p1886016892913"><a name="en-us_topic_0000001152616261_p1886016892913"></a><a name="en-us_topic_0000001152616261_p1886016892913"></a>ASCEND_OPP_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p28608892915"><a name="en-us_topic_0000001152616261_p28608892915"></a><a name="en-us_topic_0000001152616261_p28608892915"></a>Operator package (OPP) root directory. Set this variable based on the preceding example.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row144592037903"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p104601373014"><a name="en-us_topic_0000001152616261_p104601373014"></a><a name="en-us_topic_0000001152616261_p104601373014"></a>OPTION_EXEC_EXTERN_PLUGIN_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p1046013716017"><a name="en-us_topic_0000001152616261_p1046013716017"></a><a name="en-us_topic_0000001152616261_p1046013716017"></a>Path of the operator information library.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row16184379493"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p131851873492"><a name="en-us_topic_0000001152616261_p131851873492"></a><a name="en-us_topic_0000001152616261_p131851873492"></a>ASCEND_AICPU_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p181851575497"><a name="en-us_topic_0000001152616261_p181851575497"></a><a name="en-us_topic_0000001152616261_p181851575497"></a>Path of the AI CPU operator package.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row234714854615"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p2034724894619"><a name="en-us_topic_0000001152616261_p2034724894619"></a><a name="en-us_topic_0000001152616261_p2034724894619"></a>TASK_QUEUE_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p53477489462"><a name="en-us_topic_0000001152616261_p53477489462"></a><a name="en-us_topic_0000001152616261_p53477489462"></a>Whether to asynchronously deliver tasks and call the ACL APIs. You are advised to set this parameter to <strong id="en-us_topic_0000001152616261_b186701714141819"><a name="en-us_topic_0000001152616261_b186701714141819"></a><a name="en-us_topic_0000001152616261_b186701714141819"></a>1</strong> to enable this function.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row1680820246202"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p4809112415207"><a name="en-us_topic_0000001152616261_p4809112415207"></a><a name="en-us_topic_0000001152616261_p4809112415207"></a>HCCL_WHITELIST_DISABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p952814428206"><a name="en-us_topic_0000001152616261_p952814428206"></a><a name="en-us_topic_0000001152616261_p952814428206"></a>Whether to enable the communication trustlist when the HCCL is used.</p>
|
||||
<a name="ul928845132310"></a><a name="ul928845132310"></a><ul id="ul928845132310"><li><strong id="b12793231525"><a name="b12793231525"></a><a name="b12793231525"></a>0</strong>: enable the trustlist. The HCCL communication trustlist does not need to be verified.</li><li><strong id="b1146142619212"><a name="b1146142619212"></a><a name="b1146142619212"></a>1</strong>: disable the trustlist. The HCCL communication trustlist needs to be verified.</li></ul>
|
||||
<p id="en-us_topic_0000001152616261_p5809162416201"><a name="en-us_topic_0000001152616261_p5809162416201"></a><a name="en-us_topic_0000001152616261_p5809162416201"></a>The default value is <strong id="en-us_topic_0000001152616261_b1270332516435"><a name="en-us_topic_0000001152616261_b1270332516435"></a><a name="en-us_topic_0000001152616261_b1270332516435"></a>0</strong>, indicating that the trustlist is enabled by default.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row0671137162115"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p4671203792114"><a name="en-us_topic_0000001152616261_p4671203792114"></a><a name="en-us_topic_0000001152616261_p4671203792114"></a>HCCL_IF_IP</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p1822165982114"><a name="en-us_topic_0000001152616261_p1822165982114"></a><a name="en-us_topic_0000001152616261_p1822165982114"></a>IP address of the NIC for initializing communication in the HCCL.</p>
|
||||
<a name="ul2676102292415"></a><a name="ul2676102292415"></a><ul id="ul2676102292415"><li>The IP address is in dotted decimal notation.</li><li>Currently, only the host NIC is supported.</li></ul>
|
||||
<p id="en-us_topic_0000001152616261_p1167163719217"><a name="en-us_topic_0000001152616261_p1167163719217"></a><a name="en-us_topic_0000001152616261_p1167163719217"></a>By default, the host communication NICs are selected in the following sequence: NICs other than Docker/local NICs (in ascending alphabetical order of NIC names) > Docker NICs > local NICs.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0000001152616261_row1371356152313"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p15106173103120"><a name="p15106173103120"></a><a name="p15106173103120"></a>PTCOPY_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p71055317311"><a name="p71055317311"></a><a name="p71055317311"></a>Use the PTCopy operator mode to accelerate the operation of converting non-contiguous tensors to contiguous tensors and copy process. You are advised to set the value to <strong id="b114621515513"><a name="b114621515513"></a><a name="b114621515513"></a>1</strong> to enable this function. </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row743212132309"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p17433111312307"><a name="p17433111312307"></a><a name="p17433111312307"></a>ASCEND_SLOG_PRINT_TO_STDOUT</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p6433151393018"><a name="p6433151393018"></a><a name="p6433151393018"></a>(Optional) Whether to enable the log printing function.</p>
|
||||
<a name="ul760201917473"></a><a name="ul760201917473"></a><ul id="ul760201917473"><li><strong id="b1955232216215"><a name="b1955232216215"></a><a name="b1955232216215"></a>0</strong>: uses the default log output mode.</li><li><strong id="b22913272211"><a name="b22913272211"></a><a name="b22913272211"></a>1</strong>: prints the logs to the screen.</li><li>Other values: invalid</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19237171814300"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p14238161893019"><a name="p14238161893019"></a><a name="p14238161893019"></a>ASCEND_GLOBAL_LOG_LEVEL</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p223841810303"><a name="p223841810303"></a><a name="p223841810303"></a>Sets the global log level of app logs.</p>
|
||||
<a name="ul175714586453"></a><a name="ul175714586453"></a><ul id="ul175714586453"><li><strong id="b94698561835"><a name="b94698561835"></a><a name="b94698561835"></a>0</strong>: DEBUG</li><li><strong id="b1612516597314"><a name="b1612516597314"></a><a name="b1612516597314"></a>1</strong>: INFO</li><li><strong id="b82051911547"><a name="b82051911547"></a><a name="b82051911547"></a>2</strong>: WARNING</li><li><strong id="b04351021945"><a name="b04351021945"></a><a name="b04351021945"></a>3</strong>: ERROR</li><li><strong id="b116153316418"><a name="b116153316418"></a><a name="b116153316418"></a>4</strong>: NULL (no log output)</li><li>Other values: invalid</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1348192313303"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1734815235305"><a name="p1734815235305"></a><a name="p1734815235305"></a>ASCEND_GLOBAL_EVENT_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p12348202373018"><a name="p12348202373018"></a><a name="p12348202373018"></a>Whether to enable event logging for apps.</p>
|
||||
<a name="ul416352114610"></a><a name="ul416352114610"></a><ul id="ul416352114610"><li><strong id="b425610311940"><a name="b425610311940"></a><a name="b425610311940"></a>0</strong>: disabled</li><li><strong id="b198984321741"><a name="b198984321741"></a><a name="b198984321741"></a>1</strong>: enabled</li><li>Other values: invalid</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17878184693015"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1878194683016"><a name="p1878194683016"></a><a name="p1878194683016"></a>DYNAMIC_COMPILE_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p1887894620304"><a name="p1887894620304"></a><a name="p1887894620304"></a>(Optional) Dynamic shape feature, which is used when the shape changes. To enable this function, set the value to <strong id="b11281447194117"><a name="b11281447194117"></a><a name="b11281447194117"></a>1</strong>. (PyTorch 1.8.1 does not support this environment variable.)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row78312162301"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1832171673019"><a name="p1832171673019"></a><a name="p1832171673019"></a>COMBINED_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p583261643014"><a name="p583261643014"></a><a name="p583261643014"></a>(Optional) Optimizes the scenario where two inconsecutive operators are combined. To enable this function, set the value to <strong id="b19824817612"><a name="b19824817612"></a><a name="b19824817612"></a>1</strong>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17630155212342"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p66309527341"><a name="p66309527341"></a><a name="p66309527341"></a>RI_COMBINED_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p19630185220345"><a name="p19630185220345"></a><a name="p19630185220345"></a>(Optional) Optimizes the scenario where three inconsecutive operators are combined. To enable this function, set the value to <strong id="b10522121418612"><a name="b10522121418612"></a><a name="b10522121418612"></a>1</strong>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row183041355123411"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p730435533415"><a name="p730435533415"></a><a name="p730435533415"></a>ACL_DUMP_DATA</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p16304105533412"><a name="p16304105533412"></a><a name="p16304105533412"></a>(Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to <strong id="b1861154419918"><a name="b1861154419918"></a><a name="b1861154419918"></a>1</strong>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row27481914203518"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p674813144357"><a name="p674813144357"></a><a name="p674813144357"></a>DYNAMIC_OP</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p974891414353"><a name="p974891414353"></a><a name="p974891414353"></a>(Optional) Operator implementation. The performance of the ADD and MUL operators varies depending on the scenarios. This parameter is not set by default.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19173161510309"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001152616261_p16711563237"><a name="en-us_topic_0000001152616261_p16711563237"></a><a name="en-us_topic_0000001152616261_p16711563237"></a>unset GOMP_CPU_AFFINITY</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001152616261_p0711356152317"><a name="en-us_topic_0000001152616261_p0711356152317"></a><a name="en-us_topic_0000001152616261_p0711356152317"></a>(Optional) If the system is openEuler or its inherited OS, such as UOS, run this command to cancel CPU core binding.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3 id="installing-the-mixed-precision-modulemd">Installing the Mixed Precision Module</h3>
|
||||
|
||||
#### Prerequisites<a name="en-us_topic_0000001106176190_section3225481020"></a>
|
||||
|
||||
1. Ensure that the PyTorch framework adapted to Ascend AI Processors in the operating environment can be used properly.
|
||||
2. Before building and installing Apex, you have configured the environment variables on which the build depends. See [Configuring Environment Variables](#configuring-environment-variablesmd).
|
||||
|
||||
#### Installation Process<a name="en-us_topic_0000001106176190_section11880164819567"></a>
|
||||
|
||||
1. Log in to the server as the **root** user or a non-root user.
|
||||
2. Obtain the Apex source code.
|
||||
|
||||
1. Run the following command to obtain the Apex source code adapted to Ascend AI Processors:
|
||||
|
||||
```
|
||||
git clone -b 2.0.4.tr5 https://gitee.com/ascend/apex.git
|
||||
```
|
||||
|
||||
The directory structure of the downloaded source code is as follows:
|
||||
|
||||
```
|
||||
apex
|
||||
│ ├─patch # Directory of the patch adapted to Ascend AI Processors
|
||||
│ ├─npu.patch
|
||||
│ ├─scripts # Build and creation directory
|
||||
│ ├─gen.sh
|
||||
│ ├─src # Source code directory
|
||||
│ ├─tests # Directory for storing test cases
|
||||
```
|
||||
|
||||
2. Run the following commands to go to the **apex** directory and obtain the native Apex source code:
|
||||
|
||||
```
|
||||
cd apex
|
||||
git clone https://github.com/NVIDIA/apex.git
|
||||
```
|
||||
|
||||
After the native Apex source code is downloaded, the main directory structure of the code is as follows:
|
||||
|
||||
```
|
||||
apex
|
||||
│ ├─apex # Directory for storing the native Apex code
|
||||
│ ├─patch # Directory of the patch adapted to Ascend AI Processors
|
||||
│ ├─npu.patch
|
||||
│ ├─scripts # Build and creation directory
|
||||
│ ├─gen.sh
|
||||
│ ├─src # Source code directory
|
||||
│ ├─tests # Directory for storing test cases
|
||||
```
|
||||
|
||||
3. Go to the native Apex code directory, that is, **apex/apex**. Switch to the code branch whose commit ID is 4ef930c1c884fdca5f472ab2ce7cb9b505d26c1a.
|
||||
|
||||
```
|
||||
cd apex
|
||||
git checkout 4ef930c1c884fdca5f472ab2ce7cb9b505d26c1a
|
||||
```
|
||||
|
||||
> **NOTE:**
|
||||
>Due to network fluctuation, it may take a long time to obtain the source code.
|
||||
|
||||
3. Generate the Apex installation package adapted to Ascend AI Processors.
|
||||
1. Go to the **apex/scripts** directory and run the conversion script to generate full code adapted to Ascend AI Processors.
|
||||
|
||||
```
|
||||
cd ../scripts
|
||||
bash gen.sh
|
||||
```
|
||||
|
||||
The full code adapted to Ascend AI Processors is generated in the **apex/apex** directory.
|
||||
|
||||
2. Go to the full code directory **apex/apex**, and build and generate the binary installation package of Apex.
|
||||
|
||||
```
|
||||
cd ../apex
|
||||
python3 setup.py --cpp_ext --npu_float_status bdist_wheel
|
||||
```
|
||||
|
||||
The Python version must be the same as that used by PyTorch. The generated binary package is stored in the current **dist** directory, that is, **apex/apex/dist**.
|
||||
|
||||
4. <a name="en-us_topic_0000001106176190_li425495374416"></a>Install Apex.
|
||||
|
||||
Go to the **apex/apex/dist** directory and run the following command to install Apex:
|
||||
|
||||
```
|
||||
pip3 install --upgrade apex-0.1+ascend-cp37-cp37m-linux_{arch}.whl
|
||||
```
|
||||
|
||||
_\{**arch\}**_ indicates the architecture information. The value can be **aarch64** or **x86\_64**.
|
||||
|
||||
> **NOTE:**
|
||||
>To upgrade PyTorch in the environment, uninstall the PyTorch software package installed in the environment and then perform [Step 4 Install Apex](#en-us_topic_0000001106176190_li425495374416). Run the following command to check whether PyTorch has been installed:
|
||||
>**pip3 list | grep apex**
|
||||
|
||||
|
||||
<h2 id="referencesmd">References</h2>
|
||||
|
||||
- **[Installing CMake](#installing-cmakemd)**
|
||||
|
||||
- **[How Do I Install GCC 7.3.0?](#how-do-i-install-gcc-7-3-0md)**
|
||||
|
||||
- **[What to Do If "torch 1.5.0xxxx" and "torchvision" Do Not Match When torch-\*.whl Is Installed?](#what-to-do-if-torch-1-5-0xxxx-and-torchvision-do-not-match-when-torch--whl-is-installedmd)**
|
||||
|
||||
|
||||
<h3 id="installing-cmakemd">Installing CMake</h3>
|
||||
|
||||
The following describes how to install CMake 3.12.1.
|
||||
|
||||
1. Obtain the CMake software package.
|
||||
|
||||
```
|
||||
wget https://cmake.org/files/v3.12/cmake-3.12.1.tar.gz --no-check-certificate
|
||||
```
|
||||
|
||||
2. Decompress the package and go to the software package directory.
|
||||
|
||||
```
|
||||
tar -xf cmake-3.12.1.tar.gz
|
||||
cd cmake-3.12.1/
|
||||
```
|
||||
|
||||
3. Run the configuration, build, and installation commands.
|
||||
|
||||
```
|
||||
./configure --prefix=/usr/local/cmake
|
||||
make && make install
|
||||
```
|
||||
|
||||
4. Set the soft link.
|
||||
|
||||
```
|
||||
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
|
||||
```
|
||||
|
||||
5. Check whether CMake has been installed.
|
||||
```
|
||||
cmake --version
|
||||
```
|
||||
|
||||
If the message "cmake version 3.12.1" is displayed, the installation is successful.
|
||||
|
||||
|
||||
<h3 id="how-do-i-install-gcc-7-3-0md">How Do I Install GCC 7.3.0?</h3>
|
||||
|
||||
Perform the following steps as the **root** user.
|
||||
|
||||
1. Download **gcc-7.3.0.tar.gz** from [https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz).
|
||||
2. GCC installation requires adequate temporary space. Run the following command to clear the **/tmp** directory in advance:
|
||||
|
||||
```
|
||||
sudo rm -rf /tmp/*
|
||||
```
|
||||
|
||||
3. Install the dependency package. \(CentOS and Ubuntu are used as examples.\)
|
||||
- For CentOS, run the following command:
|
||||
|
||||
```
|
||||
yum install bzip2
|
||||
```
|
||||
|
||||
- For Ubuntu, run the following command:
|
||||
|
||||
```
|
||||
apt-get install bzip2
|
||||
```
|
||||
|
||||
4. Build and install GCC.
|
||||
1. Go to the directory where the source package **gcc-7.3.0.tar.gz** is located and run the following command to decompress it:
|
||||
|
||||
```
|
||||
tar -zxvf gcc-7.3.0.tar.gz
|
||||
```
|
||||
|
||||
2. Go to the extracted directory and run the following command to download the GCC dependency packages:
|
||||
|
||||
```
|
||||
cd gcc-7.3.0
|
||||
./contrib/download_prerequisites
|
||||
```
|
||||
|
||||
If an error is reported during the command execution, run the following commands in the **gcc-7.3.0/** directory to download the dependency packages:
|
||||
|
||||
```
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
|
||||
```
|
||||
|
||||
After the preceding dependencies are downloaded, run the following command again:
|
||||
|
||||
```
|
||||
./contrib/download_prerequisites
|
||||
```
|
||||
|
||||
If the validation fails, check whether the dependency packages are repeatedly downloaded. The packages should be downloaded at a time.
|
||||
|
||||
3. <a name="en-us_topic_0000001135347812_en-us_topic_0000001173199577_en-us_topic_0000001172534867_en-us_topic_0276688294_li1649343041310"></a>Run the configuration, build, and installation commands.
|
||||
|
||||
```
|
||||
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
|
||||
make -j15 # Check the number of CPUs by running grep -w processor /proc/cpuinfo|wc -l. In this example, the number is 15.
|
||||
make install
|
||||
```
|
||||
|
||||
> **NOTICE:**
|
||||
>The **--prefix** option is used to specify the linux\_gcc7.3.0 installation path, which is configurable. Do not set it to **/usr/local** or **/usr**, which is the default installation path for the GCC installed by using the software source. Otherwise, a conflict occurs and the original GCC compilation environment of the system is damaged. In this example, the installation path is set to **/usr/local/linux\_gcc7.3.0**.
|
||||
|
||||
|
||||
5. Set the environment variable.
|
||||
|
||||
Training must be performed in the compilation environment with GCC upgraded. Therefore, configure the following environment variable in your training script:
|
||||
|
||||
```
|
||||
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
|
||||
```
|
||||
|
||||
**$\{install\_path\}** indicates the GCC 7.3.0 installation path configured in [3](#en-us_topic_0000001135347812_en-us_topic_0000001173199577_en-us_topic_0000001172534867_en-us_topic_0276688294_li1649343041310). In this example, the GCC 7.3.0 installation path is **/usr/local/gcc7.3.0/**.
|
||||
|
||||
> **NOTE:**
|
||||
>Skip this step if you do not need to use the compilation environment with GCC upgraded.
|
||||
|
||||
|
||||
<h3 id="what-to-do-if-torch-1-5-0xxxx-and-torchvision-do-not-match-when-torch--whl-is-installedmd">What to Do If "torch 1.5.0xxxx" and "torchvision" Do Not Match When torch-\*.whl Is Installed?</h3>
|
||||
|
||||
#### Symptom<a name="en-us_topic_0000001105856364_en-us_topic_0175549220_section197270431505"></a>
|
||||
|
||||
During the installation of **torch-**_\*_**.whl**, the message "ERROR: torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible" is displayed.
|
||||
|
||||

|
||||
|
||||
#### Possible Causes<a name="en-us_topic_0000001105856364_en-us_topic_0175549220_section169499490501"></a>
|
||||
|
||||
When the PyTorch is installed, the version check is automatically triggered. The version of the torchvision installed in the environment is 0.6.0. During the check, it is found that the version of the **torch-**_\*_**.whl** is inconsistent with the required version 1.5.0. As a result, an error message is displayed, but the installation is successful.
|
||||
|
||||
#### Solution<a name="en-us_topic_0000001105856364_section108142031907"></a>
|
||||
|
||||
This problem has no impact on the actual result, and no action is required.
|
||||
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
|
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
|
After Width: | Height: | Size: 329 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 607 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 126 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
@@ -0,0 +1,599 @@
|
||||
# PyTorch Online Inference Guide
|
||||
- [Application Scenario](#application-scenariomd)
|
||||
- [Basic Workflow](#basic-workflowmd)
|
||||
- [Prerequisites](#prerequisitesmd)
|
||||
- [Online Inference Process](#online-inference-processmd)
|
||||
- [Environment Variable Configuration](#environment-variable-configurationmd)
|
||||
- [Sample Reference](#sample-referencemd)
|
||||
- [Special Topics](#special-topicsmd)
|
||||
- [Mixed Precision](#mixed-precisionmd)
|
||||
- [How Do I Install GCC 7.3.0?](#how-do-i-install-gcc-7-3-0md)
|
||||
<h2 id="application-scenariomd">Application Scenario</h2>
|
||||
|
||||
Online inference, unlike offline inference, allows developers to perform inference directly with PyTorch models using the **model.eval\(\)** method.
|
||||
|
||||
In this way, PyTorch-based inference apps can be directly ported to the Ascend AI Processor, which is especially useful in the data center inference scenarios.
|
||||
|
||||
### Supported Processors<a name="section15598658104219"></a>
|
||||
|
||||
Ascend 910 AI Processor
|
||||
|
||||
Ascend 710 AI Processor
|
||||
|
||||
<h2 id="basic-workflowmd">Basic Workflow</h2>
|
||||
|
||||
- **[Prerequisites](#prerequisitesmd)**
|
||||
|
||||
- **[Online Inference Process](#online-inference-processmd)**
|
||||
|
||||
- **[Environment Variable Configuration](#environment-variable-configurationmd)**
|
||||
|
||||
- **[Sample Reference](#sample-referencemd)**
|
||||
|
||||
|
||||
<h3 id="prerequisitesmd">Prerequisites</h3>
|
||||
|
||||
The PyTorch framework and mixed precision module have been installed. For details, see the _PyTorch Installation Guide_.
|
||||
|
||||
<h3 id="online-inference-processmd">Online Inference Process</h3>
|
||||
|
||||
[Figure 1](#fig13802941161818) shows the online inference process.
|
||||
|
||||
**Figure 1** Online inference process<a name="fig13802941161818"></a>
|
||||

|
||||
|
||||
<h3 id="environment-variable-configurationmd">Environment Variable Configuration</h3>
|
||||
|
||||
The following are the environment variables required for starting the inference process on PyTorch:
|
||||
|
||||
```
|
||||
# Set the environment variable for the installation path of the infrastructure software on which online inference depends. The following assumes that the installation user is HwHiAiUser, and the default installation path is used.
|
||||
# Method 1: Install Ascend-CANN-Toolkit for inference on an Ascend AI device, which serves as the development environment.
|
||||
. /home/HwHiAiUser/Ascend/ascend-toolkit/set_env.sh
|
||||
# Method 2: Install Ascend-CANN-NNAE on an Ascend AI device.
|
||||
. /home/HwHiAiUser/Ascend/nnae/set_env.sh
|
||||
|
||||
# If multiple Python 3 versions exist in the operating environment, configure the installation path of Python 3.7.5 in environment variables.
|
||||
export PATH=/usr/local/python3.7.5/bin:$PATH
|
||||
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
|
||||
|
||||
# Set the logical ID of a processor.
|
||||
export ASCEND_DEVICE_ID=0
|
||||
|
||||
# Output log information. Replace it as required.
|
||||
export ASCEND_SLOG_PRINT_TO_STDOUT=1
|
||||
export ASCEND_GLOBAL_LOG_LEVEL=0
|
||||
|
||||
# Task issued with multiple threads
|
||||
export TASK_QUEUE_ENABLE=0
|
||||
```
|
||||
|
||||
**Table 1** Description of environment variables
|
||||
|
||||
<a name="table2072027194819"></a>
|
||||
<table><thead align="left"><tr id="row1173527114812"><th class="cellrowborder" valign="top" width="46.75467546754676%" id="mcps1.2.4.1.1"><p id="p073027114816"><a name="p073027114816"></a><a name="p073027114816"></a>Environment Variable</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="43.18431843184319%" id="mcps1.2.4.1.2"><p id="p157362712480"><a name="p157362712480"></a><a name="p157362712480"></a>Description</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="10.061006100610062%" id="mcps1.2.4.1.3"><p id="p187392714485"><a name="p187392714485"></a><a name="p187392714485"></a>Required/Optional</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row2732273481"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p57382719481"><a name="p57382719481"></a><a name="p57382719481"></a>LD_LIBRARY_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p07319271480"><a name="p07319271480"></a><a name="p07319271480"></a>Dynamic library search path. Set this variable based on the preceding example.</p>
|
||||
<div class="note" id="note119943144912"><a name="note119943144912"></a><a name="note119943144912"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p49933104915"><a name="p49933104915"></a><a name="p49933104915"></a>If GCC 7.3.0 is installed in OSs such as CentOS 7.6, Debian, and BC-Linux, configure the related environment variables. For details, see <a href="#how-do-i-install-gcc-7-3-0md#en-us_topic_0000001146754749_en-us_topic_0000001072593337_l5e5c9395407d46439788b12f0e6342bc">5</a>.</p>
|
||||
</div></div>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p187352744817"><a name="p187352744817"></a><a name="p187352744817"></a>Required</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17342744812"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p4731227184818"><a name="p4731227184818"></a><a name="p4731227184818"></a>PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p97310276484"><a name="p97310276484"></a><a name="p97310276484"></a>Executable program search path. Set this variable based on the preceding example.</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p1573142711483"><a name="p1573142711483"></a><a name="p1573142711483"></a>Required</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row95241840165613"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p15242404566"><a name="p15242404566"></a><a name="p15242404566"></a>ASCEND_DEVICE_ID</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p688447526"><a name="p688447526"></a><a name="p688447526"></a>Sets the logical ID of a processor.</p>
|
||||
<p id="p178824712212"><a name="p178824712212"></a><a name="p178824712212"></a>The value range is [0, <em id="i18812110304"><a name="i18812110304"></a><a name="i18812110304"></a>N</em> – 1] and the default value is<strong id="b1381717104019"><a name="b1381717104019"></a><a name="b1381717104019"></a> 0</strong>. <em id="i1156411211703"><a name="i1156411211703"></a><a name="i1156411211703"></a>N</em> indicates the device count in the physical machine, VM, or container.</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p105245400562"><a name="p105245400562"></a><a name="p105245400562"></a>Optional</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row203705529819"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p53705522810"><a name="p53705522810"></a><a name="p53705522810"></a>ASCEND_SLOG_PRINT_TO_STDOUT</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001073203258_p763102116322"><a name="en-us_topic_0000001073203258_p763102116322"></a><a name="en-us_topic_0000001073203258_p763102116322"></a>Enables or disables log printing. Values:</p>
|
||||
<a name="en-us_topic_0000001073203258_ul95291245104113"></a><a name="en-us_topic_0000001073203258_ul95291245104113"></a><ul id="en-us_topic_0000001073203258_ul95291245104113"><li><strong id="b1877191971104041"><a name="b1877191971104041"></a><a name="b1877191971104041"></a>0</strong> or not configured: disabled</li><li><strong id="b737654378104041"><a name="b737654378104041"></a><a name="b737654378104041"></a>1</strong>: enabled</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p6370125217818"><a name="p6370125217818"></a><a name="p6370125217818"></a>Optional</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row188405280914"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p5840928594"><a name="p5840928594"></a><a name="p5840928594"></a>ASCEND_GLOBAL_LOG_LEVEL</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="en-us_topic_0000001073521184_p763102116322"><a name="en-us_topic_0000001073521184_p763102116322"></a><a name="en-us_topic_0000001073521184_p763102116322"></a>Sets the global log level. Values:</p>
|
||||
<a name="en-us_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"></a><a name="en-us_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"></a><ul id="en-us_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"><li><strong id="b1731786453104041"><a name="b1731786453104041"></a><a name="b1731786453104041"></a>0</strong>: DEBUG</li><li><strong id="b758139838104041"><a name="b758139838104041"></a><a name="b758139838104041"></a>1</strong>: INFO</li><li><strong id="b539270545104041"><a name="b539270545104041"></a><a name="b539270545104041"></a>2</strong>: WARNING</li><li><strong id="b444623067104041"><a name="b444623067104041"></a><a name="b444623067104041"></a>3</strong>: ERROR</li><li><strong id="b1157662181104041"><a name="b1157662181104041"></a><a name="b1157662181104041"></a>4</strong>: NULL (no log output)</li><li>Other values: invalid</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p6841928598"><a name="p6841928598"></a><a name="p6841928598"></a>Optional</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17638114219104"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p20638342191018"><a name="p20638342191018"></a><a name="p20638342191018"></a>TASK_QUEUE_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p126381842151019"><a name="p126381842151019"></a><a name="p126381842151019"></a>Enables or disables the task delivery in multi-thread mode. When this function is enabled, the training performance of the entire network is improved in most cases. Values:</p>
|
||||
<a name="ul6194152711118"></a><a name="ul6194152711118"></a><ul id="ul6194152711118"><li><strong id="b166811333191713"><a name="b166811333191713"></a><a name="b166811333191713"></a>0</strong> or not configured: disabled</li><li><strong id="b3865153321914"><a name="b3865153321914"></a><a name="b3865153321914"></a>1</strong>: enabled</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p86386423103"><a name="p86386423103"></a><a name="p86386423103"></a>Optional</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
> **NOTE:**
|
||||
>For more log information, see the _CANN Log Reference_.
|
||||
|
||||
<h3 id="sample-referencemd">Sample Reference</h3>
|
||||
|
||||
#### Sample Code<a name="section2017032418274"></a>
|
||||
|
||||
Try to minimize the initialization frequency across the app lifetime during inference. The inference mode is set using the **model.eval\(\)** method, and the inference process must run under the code branch **with torch.no\_grad\(\):**.
|
||||
|
||||
The following uses Python code of the ResNet-50 network as an example for description.
|
||||
|
||||
**resnet50\_infer\_for\_pytorch.py** sample code:
|
||||
|
||||
```
|
||||
import argparse
|
||||
import os
|
||||
import time
|
||||
import torch
|
||||
import torch.nn.parallel
|
||||
import torch.optim
|
||||
import torch.utils.data
|
||||
import torch.utils.data.distributed
|
||||
import torchvision.transforms as transforms
|
||||
import torchvision.datasets as datasets
|
||||
import torchvision.models as models
|
||||
|
||||
import torch.npu
|
||||
from apex import amp
|
||||
|
||||
model_names = sorted(name for name in models.__dict__
|
||||
if name.islower() and not name.startswith("__")
|
||||
and callable(models.__dict__[name]))
|
||||
|
||||
|
||||
def parse_args():
|
||||
""" User-defined dataset path and model path """
|
||||
parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
|
||||
parser.add_argument('--data', metavar='DIR', default="/data/imagenet",
|
||||
help='path to dataset')
|
||||
parser.add_argument('-a', '--arch', metavar='ARCH', default='resnet50',
|
||||
choices=model_names,
|
||||
help='model architecture: ' +
|
||||
' | '.join(model_names) +
|
||||
' (default: resnet18)')
|
||||
|
||||
parser.add_argument('--epochs', default=100, type=int, metavar='N',
|
||||
help='number of total epochs to run')
|
||||
|
||||
parser.add_argument('-b', '--batch_size', default=512, type=int,
|
||||
metavar='N',
|
||||
help='mini-batch size (default: 256), this is the total '
|
||||
'batch size of all GPUs on the current node when '
|
||||
'using Data Parallel or Distributed Data Parallel')
|
||||
|
||||
parser.add_argument('--resume', default='', type=str, metavar='PATH',
|
||||
help='path to latest checkpoint (default: none)')
|
||||
|
||||
parser.add_argument('--pretrained', dest='pretrained', action='store_true',
|
||||
help='use pre-trained model')
|
||||
|
||||
parser.add_argument('--npu', default=None, type=int,
|
||||
help='NPU id to use.')
|
||||
|
||||
parser.add_argument('-j', '--workers', default=32, type=int, metavar='N',
|
||||
help='number of data loading workers (default: 8)')
|
||||
|
||||
parser.add_argument('--lr', '--learning_rate', default=0.1, type=float,
|
||||
metavar='LR', help='initial learning rate', dest='lr')
|
||||
parser.add_argument('--wd', '--weight_decay', default=1e-4, type=float,
|
||||
metavar='W', help='weight decay (default: 1e-4)',
|
||||
dest='weight_decay')
|
||||
|
||||
args, unknown_args = parser.parse_known_args()
|
||||
if len(unknown_args) > 0:
|
||||
for bad_arg in unknown_args:
|
||||
print("ERROR: Unknown command line arg: %s" % bad_arg)
|
||||
raise ValueError("Invalid command line arg(s)")
|
||||
|
||||
return args
|
||||
|
||||
|
||||
# =========================================================================
|
||||
# Main function entry
|
||||
# =========================================================================
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args.npu is None:
|
||||
args.npu = 0
|
||||
global CALCULATE_DEVICE
|
||||
CALCULATE_DEVICE = "npu:{}".format(args.npu)
|
||||
torch.npu.set_device(CALCULATE_DEVICE)
|
||||
print("use ", CALCULATE_DEVICE)
|
||||
main_worker(args.npu, args)
|
||||
|
||||
|
||||
def main_worker(npu, args):
|
||||
global best_acc1
|
||||
args.npu = npu
|
||||
|
||||
# =========================================================================
|
||||
# Create a model.
|
||||
# =========================================================================
|
||||
print("=> creating model '{}'".format(args.arch))
|
||||
model = models.__dict__[args.arch](zero_init_residual=True)
|
||||
|
||||
# Copy the model data to the Ascend AI Processor.
|
||||
model = model.to(CALCULATE_DEVICE)
|
||||
|
||||
optimizer = torch.optim.SGD([
|
||||
{'params': [param for name, param in model.named_parameters() if name[-4:] == 'bias'], 'weight_decay': 0.0},
|
||||
{'params': [param for name, param in model.named_parameters() if name[-4:] != 'bias'],
|
||||
'weight_decay': args.weight_decay}],
|
||||
args.lr)
|
||||
|
||||
# =========================================================================
|
||||
# Initialize the mixed precision model. After the model is used, the calculation can be accelerated, but the accuracy may slightly decrease. Determine whether to use the model based on the actual scenario.
|
||||
# =========================================================================
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level="O2", loss_scale=1024, verbosity=1)
|
||||
|
||||
# =========================================================================
|
||||
# Load the trained model parameters.
|
||||
# =========================================================================
|
||||
# Restore model parameters from the model file.
|
||||
if os.path.isfile(args.resume):
|
||||
print("=> loading checkpoint '{}'".format(args.resume))
|
||||
checkpoint = torch.load(args.resume)
|
||||
|
||||
best_acc1 = checkpoint['best_acc1']
|
||||
best_acc1 = best_acc1.to("npu:{}".format(args.npu))
|
||||
|
||||
model.load_state_dict(checkpoint['state_dict'])
|
||||
print("=> loaded checkpoint '{}' (epoch {})".format(args.resume, checkpoint['epoch']))
|
||||
|
||||
else:
|
||||
print("=> no checkpoint found at '{}'".format(args.resume))
|
||||
|
||||
# =========================================================================
|
||||
# Initialize the database.
|
||||
# =========================================================================
|
||||
# Load and preprocess image data.
|
||||
valdir = os.path.join(args.data, 'val')
|
||||
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
|
||||
std=[0.229, 0.224, 0.225])
|
||||
|
||||
val_loader = torch.utils.data.DataLoader(
|
||||
datasets.ImageFolder(valdir, transforms.Compose([
|
||||
transforms.Resize(256),
|
||||
transforms.CenterCrop(224),
|
||||
transforms.ToTensor(),
|
||||
normalize,
|
||||
])),
|
||||
batch_size=args.batch_size, shuffle=True,
|
||||
num_workers=args.workers, pin_memory=True)
|
||||
|
||||
# =========================================================================
|
||||
# Run the validate command.
|
||||
# =========================================================================
|
||||
validate(val_loader, model, args)
|
||||
|
||||
|
||||
# =========================================================================
|
||||
# Implement the sample API for online inference.
|
||||
# =========================================================================
|
||||
def validate(val_loader, model, args):
|
||||
batch_time = AverageMeter('Time', ':6.3f')
|
||||
top1 = AverageMeter('Acc@1', ':6.2f')
|
||||
top5 = AverageMeter('Acc@5', ':6.2f')
|
||||
progress = ProgressMeter(
|
||||
len(val_loader),
|
||||
[batch_time, top1, top5],
|
||||
prefix='Test: ')
|
||||
|
||||
# =========================================================================
|
||||
# Switch to the inference mode.
|
||||
# =========================================================================
|
||||
model.eval()
|
||||
|
||||
# =========================================================================
|
||||
# Execute the model forward propagation under the torch.no_grad(): branch.
|
||||
# =========================================================================
|
||||
with torch.no_grad():
|
||||
end = time.time()
|
||||
for i, (images, target) in enumerate(val_loader):
|
||||
|
||||
# Place the image data on the NPU.
|
||||
images = images.to(CALCULATE_DEVICE, non_blocking=True)
|
||||
target = target.to(torch.int32).to(CALCULATE_DEVICE, non_blocking=True)
|
||||
|
||||
# Calculate the output.
|
||||
output = model(images)
|
||||
|
||||
# Collect statistics on result precisions.
|
||||
acc1, acc5 = accuracy(output, target, topk=(1, 5))
|
||||
top1.update(acc1[0], images.size(0))
|
||||
top5.update(acc5[0], images.size(0))
|
||||
|
||||
# Measure the running time.
|
||||
batch_time.update(time.time() - end)
|
||||
end = time.time()
|
||||
|
||||
# Print inference logs.
|
||||
progress.display(i)
|
||||
|
||||
print(' * Acc@1 {top1.avg:.3f} Acc@5 {top5.avg:.3f}'.format(top1=top1, top5=top5))
|
||||
|
||||
return top1.avg
|
||||
|
||||
|
||||
class AverageMeter(object):
|
||||
"""Calculate and store the average value and current value."""
|
||||
def __init__(self, name, fmt=':f'):
|
||||
self.name = name
|
||||
self.fmt = fmt
|
||||
self.reset()
|
||||
self.start_count_index = 10
|
||||
|
||||
def reset(self):
|
||||
self.val = 0
|
||||
self.avg = 0
|
||||
self.sum = 0
|
||||
self.count = 0
|
||||
|
||||
def update(self, val, n=1):
|
||||
if self.count == 0:
|
||||
self.batchsize = n
|
||||
|
||||
self.val = val
|
||||
self.count += n
|
||||
if self.count > (self.start_count_index * self.batchsize):
|
||||
self.sum += val * n
|
||||
self.avg = self.sum / (self.count - self.start_count_index * self.batchsize)
|
||||
|
||||
def __str__(self):
|
||||
fmtstr = '{name} {val' + self.fmt + '} ({avg' + self.fmt + '})'
|
||||
return fmtstr.format(**self.__dict__)
|
||||
|
||||
|
||||
class ProgressMeter(object):
|
||||
"""Record model computing information."""
|
||||
def __init__(self, num_batches, meters, prefix=""):
|
||||
self.batch_fmtstr = self._get_batch_fmtstr(num_batches)
|
||||
self.meters = meters
|
||||
self.prefix = prefix
|
||||
|
||||
def display(self, batch):
|
||||
entries = [self.prefix + self.batch_fmtstr.format(batch)]
|
||||
entries += [str(meter) for meter in self.meters]
|
||||
print('\t'.join(entries))
|
||||
|
||||
def _get_batch_fmtstr(self, num_batches):
|
||||
num_digits = len(str(num_batches // 1))
|
||||
fmt = '{:' + str(num_digits) + 'd}'
|
||||
return '[' + fmt + '/' + fmt.format(num_batches) + ']'
|
||||
|
||||
|
||||
def accuracy(output, target, topk=(1,)):
|
||||
"""Calculate the precision of k top predictions based on the specified value k."""
|
||||
with torch.no_grad():
|
||||
maxk = max(topk)
|
||||
batch_size = target.size(0)
|
||||
|
||||
_, pred = output.topk(maxk, 1, True, True)
|
||||
pred = pred.t()
|
||||
correct = pred.eq(target.view(1, -1).expand_as(pred))
|
||||
|
||||
res = []
|
||||
for k in topk:
|
||||
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
|
||||
res.append(correct_k.mul_(100.0 / batch_size))
|
||||
return res
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
```
|
||||
|
||||
#### Sample Running<a name="section340764716270"></a>
|
||||
|
||||
The following uses the ResNet-50 model as an example to describe how to perform online inference.
|
||||
|
||||
1. Download a pre-trained model.
|
||||
|
||||
Visit [Ascend ModelZoo](https://www.hiascend.com/en/software/modelzoo) and click **Download Model** to download a pre-trained ResNet-50 model.
|
||||
|
||||
2. Edit the inference script.
|
||||
|
||||
Create a model script file **resnet50\_infer\_for\_pytorch.py** and write code. For how to write the code, see [Sample Code]().
|
||||
|
||||
3. Run inference.
|
||||
|
||||
Set environment variables (for how to set them, see [Environment Variable Configuration](#environment-variable-configurationmd)) and then run the following command:
|
||||
|
||||
```
|
||||
python3 pytorch-resnet50-apex.py --data /data/imagenet \
|
||||
--npu 7 \
|
||||
--epochs 90 \
|
||||
--resume ./checkpoint.pth.tar # ./checkpoint.pth.tar is the path of the sample pre-trained model file.
|
||||
```
|
||||
|
||||
> **NOTE:**
|
||||
>The preceding command is an example only. Modify the arguments as needed.
|
||||
|
||||
|
||||
<h2 id="special-topicsmd">Special Topics</h2>
|
||||
|
||||
- **[Mixed Precision](#mixed-precisionmd)**
|
||||
|
||||
|
||||
<h3 id="mixed-precisionmd">Mixed Precision</h3>
|
||||
|
||||
#### Overview<a name="section14734122962615"></a>
|
||||
|
||||
Based on the architecture features of the NPU, mixed precision is involved in the model computing, that is, the scenario where the float16 and float32 data types are used together. Replacing float32 with float16 has the following advantages:
|
||||
|
||||
- The memory usage of intermediate variables is reduced.
|
||||
- The data transfer time decreases because the memory usage is reduced.
|
||||
- The compute units of float16 provide better computing performance.
|
||||
|
||||
However, the mixed precision training is limited by the precision range expressed by float16. If float32 is converted into float16, the training convergence is affected. To use float16 for acceleration in some computations and ensure training convergence, the mixed precision module Apex is used. The mixed precision module Apex is a comprehensive optimization library that features high optimization performance and precision.
|
||||
|
||||
#### Supported Features<a name="section175201458521"></a>
|
||||
|
||||
[Table 1](#en-us_topic_0278765773_table10717173813332) describes the functions and optimization of the mixed precision module.
|
||||
|
||||
**Table 1** Functions of the mixed precision module
|
||||
|
||||
<a name="en-us_topic_0278765773_table10717173813332"></a>
|
||||
<table><thead align="left"><tr id="en-us_topic_0278765773_row371716385333"><th class="cellrowborder" valign="top" width="32.269999999999996%" id="mcps1.2.3.1.1"><p id="en-us_topic_0278765773_p13717163815333"><a name="en-us_topic_0278765773_p13717163815333"></a><a name="en-us_topic_0278765773_p13717163815333"></a>Function</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="67.73%" id="mcps1.2.3.1.2"><p id="en-us_topic_0278765773_p14400173910345"><a name="en-us_topic_0278765773_p14400173910345"></a><a name="en-us_topic_0278765773_p14400173910345"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="en-us_topic_0278765773_row1571763813334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0278765773_p4502732153412"><a name="en-us_topic_0278765773_p4502732153412"></a><a name="en-us_topic_0278765773_p4502732153412"></a>O1 configuration</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0278765773_p640053920348"><a name="en-us_topic_0278765773_p640053920348"></a><a name="en-us_topic_0278765773_p640053920348"></a>Conv and Matmul use float16 for computing, and Softmax and BN use float32.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0278765773_row3717173817336"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0278765773_p11503103210344"><a name="en-us_topic_0278765773_p11503103210344"></a><a name="en-us_topic_0278765773_p11503103210344"></a>O2 configuration</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0278765773_p164001639143419"><a name="en-us_topic_0278765773_p164001639143419"></a><a name="en-us_topic_0278765773_p164001639143419"></a>BN uses float32, and others use float16.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0278765773_row14717193815334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0278765773_p1950318328349"><a name="en-us_topic_0278765773_p1950318328349"></a><a name="en-us_topic_0278765773_p1950318328349"></a>Static loss scale</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0278765773_p1440033983418"><a name="en-us_topic_0278765773_p1440033983418"></a><a name="en-us_topic_0278765773_p1440033983418"></a>Parameters are statically set to ensure the convergence of mixed precision training.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="en-us_topic_0278765773_row871733813317"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0278765773_p1550303243417"><a name="en-us_topic_0278765773_p1550303243417"></a><a name="en-us_topic_0278765773_p1550303243417"></a>Dynamic loss scale</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0278765773_p15400143963412"><a name="en-us_topic_0278765773_p15400143963412"></a><a name="en-us_topic_0278765773_p15400143963412"></a>The loss scale value is dynamically calculated to determine whether overflow occurs.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
> **NOTE:**
|
||||
>In the current version, Apex is implemented using Python and does not support AscendCL or CUDA optimization.
|
||||
|
||||
#### Initializing the Mixed Precision Model<a name="section18178125518268"></a>
|
||||
|
||||
1. To use the mixed precision module Apex, import the amp module from the Apex library.
|
||||
|
||||
```
|
||||
from apex import amp
|
||||
```
|
||||
|
||||
2. Initialize the amp module so that it can modify the model, optimizer, and PyTorch internal functions.
|
||||
|
||||
```
|
||||
model, optimizer = amp.initialize(model, optimizer)
|
||||
```
|
||||
|
||||
For details, see "Initialize the mixed precision model."# in [Sample Code](#sample-referencemd).
|
||||
|
||||
```
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level="O2", loss_scale=1024, verbosity=1)
|
||||
```
|
||||
|
||||
|
||||
#### Mixed Precision Inference<a name="section818071513288"></a>
|
||||
|
||||
After the mixed precision model is initialized, perform model forward propagation.
|
||||
|
||||
Sample code: For details, see the implementation of **validate\(val\_loader, model, args\)** in [Sample Code](#sample-referencemd).
|
||||
|
||||
<h2 id="how-do-i-install-gcc-7-3-0md">How Do I Install GCC 7.3.0?</h2>
|
||||
|
||||
Perform the following steps as the **root** user.
|
||||
|
||||
1. Download **gcc-7.3.0.tar.gz** from [https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz).
|
||||
2. To install GCC, you need to reserve adequate temporary space. Run the following command to clear the **/tmp** directory before the installation:
|
||||
|
||||
```
|
||||
sudo rm -rf /tmp/*
|
||||
```
|
||||
|
||||
3. Install the dependency package. \(CentOS and Ubuntu are used as examples.\)
|
||||
- For CentOS, run the following command:
|
||||
|
||||
```
|
||||
yum install bzip2
|
||||
```
|
||||
|
||||
- For Ubuntu, run the following command:
|
||||
|
||||
```
|
||||
apt-get install bzip2
|
||||
```
|
||||
|
||||
4. Build and install GCC.
|
||||
1. Go to the directory where the source code package **gcc-7.3.0.tar.gz** is located and run the following command to extract it:
|
||||
|
||||
```
|
||||
tar -zxvf gcc-7.3.0.tar.gz
|
||||
```
|
||||
|
||||
2. Go to the extracted directory and run the following command to download the GCC dependency packages:
|
||||
|
||||
```
|
||||
cd gcc-7.3.0
|
||||
./contrib/download_prerequisites
|
||||
```
|
||||
|
||||
If an error is reported during the command execution, run the following commands in the **gcc-7.3.0/** directory to download the dependency packages:
|
||||
|
||||
```
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
|
||||
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
|
||||
```
|
||||
|
||||
After downloading the preceding dependency packages, run the following command:
|
||||
|
||||
```
|
||||
./contrib/download_prerequisites
|
||||
```
|
||||
|
||||
If the verification fails, check whether the dependency package is repeatedly downloaded. The package should be downloaded at a time.
|
||||
|
||||
3. <a name="en-us_topic_0000001146754749_en-us_topic_0000001072593337_l75d31a2874534a2092e80a5f865b46f0"></a>Run the following commands for configuration, build, and installation.
|
||||
|
||||
```
|
||||
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
|
||||
make -j15 # The value 15 indicates the number of CPUs, which is configurable and can be queried by running grep -w processor /proc/cpuinfo|wc -l.
|
||||
make install
|
||||
```
|
||||
|
||||
> **NOTICE:**
|
||||
>The **--prefix** parameter is used to specify the linux\_gcc7.3.0 installation path, which is configurable. Do not set it to **/usr/local** or **/usr**, which is the default installation path for the GCC installed by using the software source. Otherwise, a conflict occurs and the original GCC compilation environment of the system is damaged. In this example, the installation path is set to **/usr/local/linux\_gcc7.3.0**.
|
||||
|
||||
|
||||
5. Set the environment variable.
|
||||
|
||||
Training must be performed in the compilation environment with GCC upgraded. Therefore, configure the following environment variable in the training script:
|
||||
|
||||
```
|
||||
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
|
||||
```
|
||||
|
||||
**$\{install\_path\}** indicates the GCC 7.3.0 installation path configured in [3.](#en-us_topic_0000001146754749_en-us_topic_0000001072593337_l75d31a2874534a2092e80a5f865b46f0). In this example, the GCC 7.3.0 installation path is **/usr/local/linux\_gcc7.3.0/**.
|
||||
|
||||
> **NOTE:**
|
||||
>Skip this step if you do not the compilation environment with GCC upgraded.
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 580 B |
@@ -0,0 +1,493 @@
|
||||
# FrameworkPTAdapter 2.0.4 Release Notes
|
||||
|
||||
- [FrameworkPTAdapter 2.0.4 Release Notes](#frameworkptadapter-204-release-notes)
|
||||
- [FrameworkPTAdapter 2.0.4](#frameworkptadapter-204)
|
||||
- [Before You Start](#before-you-start)
|
||||
- [New Features](#new-features)
|
||||
- [Modified Features](#modified-features)
|
||||
- [Resolved Issues](#resolved-issues)
|
||||
- [Known Issues](#known-issues)
|
||||
- [Compatibility](#compatibility)
|
||||
- [FrameworkPTAdapter 2.0.3](#frameworkptadapter-203)
|
||||
- [Before You Start](#before-you-start-1)
|
||||
- [New Features](#new-features-1)
|
||||
- [Modified Features](#modified-features-1)
|
||||
- [Resolved Issues](#resolved-issues-1)
|
||||
- [Known Issues](#known-issues-1)
|
||||
- [Compatibility](#compatibility-1)
|
||||
- [FrameworkPTAdapter 2.0.2](#frameworkptadapter-202)
|
||||
- [Before You Start](#before-you-start-2)
|
||||
- [New Features](#new-features-2)
|
||||
- [Modified Features](#modified-features-2)
|
||||
- [Resolved Issues](#resolved-issues-2)
|
||||
- [Known Issues](#known-issues-2)
|
||||
- [Compatibility](#compatibility-2)
|
||||
|
||||
## FrameworkPTAdapter 2.0.4
|
||||
### Before You Start
|
||||
|
||||
This framework is modified based on the open-source PyTorch 1.5.0 and 1.8.1 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
|
||||
|
||||
PyTorch 1.8.1 inherits the features of PyTorch 1.5.0. Their functions are basically the same, but PyTorch 1.8.1 provides better development experience for backend operator adaptation. Currently, PyTorch 1.8.1 supports only the ResNet-50 network model.
|
||||
### New Features
|
||||
|
||||
**Table 1** Features supported by PyTorch
|
||||
|
||||
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row7979351559"><td class="cellrowborder" rowspan="3" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.5.0 features adapted to NPUs</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Optimization of Model Accuracy Analyzer</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported mapping between IR and TBE operators and enabled the NPU dump data to be loaded to the GPU side for comparison.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>E2E prof</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Integrated the profile data obtained by the native PyTorch Profiling tool and CANN prof tool to implement end-to-end model and operator performance analysis.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Basic framework functions</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Added the function of adapted operator development. For details, see the operator list.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.8.1 features adapted to NPUs</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>AMP</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported the native training with automatic mixed precision (AMP) of PyTorch.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>Profiling</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Supported the native profiling function of PyTorch.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>OS compatibility</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>OS compatibility</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported Ubuntu 20.04 (x86 and ARM) and EulerOS 2.10 (ARM).</p>
|
||||
</td>
|
||||
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Python version compatibility</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Supported compilation and use of Python 3.9 (only in PyTorch 1.8.1).</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Modified Features
|
||||
|
||||
N/A
|
||||
### Resolved Issues
|
||||
|
||||
N/A
|
||||
### Known Issues
|
||||
|
||||
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
|
||||
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Compatibility
|
||||
|
||||
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04/2.04, BC-Linux 7.6, Debian 9.9, Debian 10, openEuler 20.03 LTS
|
||||
|
||||
Atlas 800 (model 9000): CentOS 7.6, Ubuntu 18.04/2.04, EulerOS 2.8/2.10, Kylin V10, BC-Linux 7.6, openEuler 20.03 LTS, UOS 20 1020e
|
||||
## FrameworkPTAdapter 2.0.3
|
||||
### Before You Start
|
||||
|
||||
This framework is modified based on the open-source PyTorch 1.5.0 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
|
||||
|
||||
PyTorch 1.8.1 is supported by this version and later, and this version inherits the features of PyTorch 1.5.0 and provides the same functions, except for the Profiling tool. In addition, it optimizes the backend operator adaptation. Currently, PyTorch 1.8.1 supports only the ResNet-50 network model.
|
||||
### New Features
|
||||
|
||||
**Table 1** Features supported by PyTorch
|
||||
|
||||
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row7979351559"><td class="cellrowborder" rowspan="5" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch features adapted to NPUs</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>PyTorch 1.8.1</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Added PyTorch 1.8.1. Currently, only the ResNet-50 network is supported, including the training scenario for distributed data parallel (DDP).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>Python 3.8</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Supported compilation and use of Python 3.8.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Operator overflow/underflow detection tool</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Supported IR-level operator overflow/underflow detection in the PyTorch framework. When an AI Core operator overflow/underflow occurs, the IR information is displayed.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row185381431133610"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p953883153611"><a name="p953883153611"></a><a name="p953883153611"></a>OS compatibility</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p13538203153618"><a name="p13538203153618"></a><a name="p13538203153618"></a>Supported UOS 20 1020e ARM.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row91681125173610"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2168172519364"><a name="p2168172519364"></a><a name="p2168172519364"></a>Basic framework functions</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1416815259367"><a name="p1416815259367"></a><a name="p1416815259367"></a>Added the function of adapted operator development. For details, see the operator list.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11970351050"><td class="cellrowborder" rowspan="26" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p298314333514"><a name="p298314333514"></a><a name="p298314333514"></a>Model training</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p19984193312511"><a name="p19984193312511"></a><a name="p19984193312511"></a>CenterFace</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p7517351258"><a name="p7517351258"></a><a name="p7517351258"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row9965351254"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1984033458"><a name="p1984033458"></a><a name="p1984033458"></a>PCBU</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p298411338513"><a name="p298411338513"></a><a name="p298411338513"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row14966351959"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p198414331957"><a name="p198414331957"></a><a name="p198414331957"></a>Net++</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1798413331756"><a name="p1798413331756"></a><a name="p1798413331756"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row20966351454"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4984183317518"><a name="p4984183317518"></a><a name="p4984183317518"></a>FCN8S</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1698453311519"><a name="p1698453311519"></a><a name="p1698453311519"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19653517518"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1298483319512"><a name="p1298483319512"></a><a name="p1298483319512"></a>OSNetRetinaFace</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1798423312519"><a name="p1798423312519"></a><a name="p1798423312519"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row39619351751"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1298414331513"><a name="p1298414331513"></a><a name="p1298414331513"></a>PSPnet</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10984633254"><a name="p10984633254"></a><a name="p10984633254"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row496335654"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19984433351"><a name="p19984433351"></a><a name="p19984433351"></a>EDSR</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p898473314517"><a name="p898473314517"></a><a name="p898473314517"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17953357517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p14984123312515"><a name="p14984123312515"></a><a name="p14984123312515"></a>Tsm</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p159841033855"><a name="p159841033855"></a><a name="p159841033855"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16951435551"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19984933457"><a name="p19984933457"></a><a name="p19984933457"></a>pnasnet5large</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p89846335512"><a name="p89846335512"></a><a name="p89846335512"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row2095113520514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1798416331952"><a name="p1798416331952"></a><a name="p1798416331952"></a>Gaitset</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p098417336516"><a name="p098417336516"></a><a name="p098417336516"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row89516351511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11985153312516"><a name="p11985153312516"></a><a name="p11985153312516"></a>fcn</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p169858331155"><a name="p169858331155"></a><a name="p169858331155"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row5953353513"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18985103311514"><a name="p18985103311514"></a><a name="p18985103311514"></a>Albert</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2098513334519"><a name="p2098513334519"></a><a name="p2098513334519"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row119533516513"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p598511336511"><a name="p598511336511"></a><a name="p598511336511"></a>AdvancedEast</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p119850331513"><a name="p119850331513"></a><a name="p119850331513"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row39511356512"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p698553311512"><a name="p698553311512"></a><a name="p698553311512"></a>ReidStrongBaseline</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1198514331659"><a name="p1198514331659"></a><a name="p1198514331659"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row129463518517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p99851633158"><a name="p99851633158"></a><a name="p99851633158"></a>Fast-scnn</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1298514331359"><a name="p1298514331359"></a><a name="p1298514331359"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row9942035757"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p109854331151"><a name="p109854331151"></a><a name="p109854331151"></a>RDN</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1198583317511"><a name="p1198583317511"></a><a name="p1198583317511"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row79415357517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6985833351"><a name="p6985833351"></a><a name="p6985833351"></a>SRFlow</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p29851033350"><a name="p29851033350"></a><a name="p29851033350"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row12947357514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149859334518"><a name="p149859334518"></a><a name="p149859334518"></a>MGN</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19851833850"><a name="p19851833850"></a><a name="p19851833850"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row3941735855"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p898533316518"><a name="p898533316518"></a><a name="p898533316518"></a>Roberta</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p998553318518"><a name="p998553318518"></a><a name="p998553318518"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1093335856"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1985533451"><a name="p1985533451"></a><a name="p1985533451"></a>RegNetY</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p59851033355"><a name="p59851033355"></a><a name="p59851033355"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row49373518516"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19986173311512"><a name="p19986173311512"></a><a name="p19986173311512"></a>VoVNet-39</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p798683310515"><a name="p798683310515"></a><a name="p798683310515"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row5930351357"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p189862336515"><a name="p189862336515"></a><a name="p189862336515"></a>RegNetX</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1398618331651"><a name="p1398618331651"></a><a name="p1398618331651"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row169312351655"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149863337513"><a name="p149863337513"></a><a name="p149863337513"></a>RefineNet</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2098615331959"><a name="p2098615331959"></a><a name="p2098615331959"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11931235957"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1198616331657"><a name="p1198616331657"></a><a name="p1198616331657"></a>RefineDet</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1698611332518"><a name="p1698611332518"></a><a name="p1698611332518"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row189215359511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p16986183319512"><a name="p16986183319512"></a><a name="p16986183319512"></a>AlignedReID</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1898715331055"><a name="p1898715331055"></a><a name="p1898715331055"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row89213351858"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p119878330511"><a name="p119878330511"></a><a name="p119878330511"></a>FaceBoxes</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p129878331158"><a name="p129878331158"></a><a name="p129878331158"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Modified Features
|
||||
|
||||
N/A
|
||||
### Resolved Issues
|
||||
|
||||
N/A
|
||||
### Known Issues
|
||||
|
||||
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
|
||||
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Compatibility
|
||||
|
||||
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04, BC-Linux 7.6, Debian 9.9, Debian 10, and openEuler 20.03 LTS.
|
||||
|
||||
Atlas 800 (model 9000): CentOS 7.6, Euler 2.8, Kylin v10, BC-Linux 7.6, OpenEuler 20.03 LTS, and UOS 20 1020e.
|
||||
|
||||
## FrameworkPTAdapter 2.0.2
|
||||
### Before You Start
|
||||
|
||||
This framework is modified based on the open-source PyTorch 1.5.0 primarily developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
|
||||
### New Features
|
||||
|
||||
**Table 1** Features supported by PyTorch
|
||||
|
||||
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.489999999999998%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="26.3%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="63.21%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row171322953713"><td class="cellrowborder" rowspan="7" valign="top" width="10.489999999999998%" headers="mcps1.2.4.1.1 "><p id="p10237517181"><a name="p10237517181"></a><a name="p10237517181"></a>Adapted training models</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.3%" headers="mcps1.2.4.1.2 "><p id="p6134294377"><a name="p6134294377"></a><a name="p6134294377"></a>YOLOv4</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.21%" headers="mcps1.2.4.1.3 "><p id="p314533811397"><a name="p314533811397"></a><a name="p314533811397"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row15990182233714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p399019224374"><a name="p399019224374"></a><a name="p399019224374"></a>YOLOv3</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1714553816396"><a name="p1714553816396"></a><a name="p1714553816396"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row5301255373"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1530325123719"><a name="p1530325123719"></a><a name="p1530325123719"></a>DB</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p5146193819390"><a name="p5146193819390"></a><a name="p5146193819390"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row274203413712"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p197423343379"><a name="p197423343379"></a><a name="p197423343379"></a>RFCN</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15828941153919"><a name="p15828941153919"></a><a name="p15828941153919"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row78671918163714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p188671318183713"><a name="p188671318183713"></a><a name="p188671318183713"></a>CRNN</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10828241123917"><a name="p10828241123917"></a><a name="p10828241123917"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16912221171"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6913132676"><a name="p6913132676"></a><a name="p6913132676"></a>Densenset161</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p209131221474"><a name="p209131221474"></a><a name="p209131221474"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1016073314719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p3160153320717"><a name="p3160153320717"></a><a name="p3160153320717"></a>Densenset191</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1516012331173"><a name="p1516012331173"></a><a name="p1516012331173"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row9627165910386"><td class="cellrowborder" rowspan="4" valign="top" width="10.489999999999998%" headers="mcps1.2.4.1.1 "><p id="p1561535993811"><a name="p1561535993811"></a><a name="p1561535993811"></a>PyTorch features adapted to NPUs</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="26.3%" headers="mcps1.2.4.1.2 "><p id="p136151659163819"><a name="p136151659163819"></a><a name="p136151659163819"></a>Basic framework functions</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="63.21%" headers="mcps1.2.4.1.3 "><p id="p1661535983813"><a name="p1661535983813"></a><a name="p1661535983813"></a>Added the function of adapted operator development. For details, see the operator list.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row7627155917380"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1561525916383"><a name="p1561525916383"></a><a name="p1561525916383"></a>Model Accuracy Analyzer</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19616115953816"><a name="p19616115953816"></a><a name="p19616115953816"></a>Added the Model Accuracy Analyzer and supported training accuracy demarcation.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row46269593383"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p0616559163819"><a name="p0616559163819"></a><a name="p0616559163819"></a>Ascend 710 AI Processor</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p186161459193813"><a name="p186161459193813"></a><a name="p186161459193813"></a>Supported the online inference on Ascend 710 AI Processors.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row76261059153817"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11616175953812"><a name="p11616175953812"></a><a name="p11616175953812"></a>OS compatibility</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p8935115971714"><a name="p8935115971714"></a><a name="p8935115971714"></a>Supported Ubuntu 18.04.5 and openEuler 20.03 LTS.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Modified Features
|
||||
|
||||
N/A
|
||||
### Resolved Issues
|
||||
|
||||
N/A
|
||||
### Known Issues
|
||||
|
||||
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
|
||||
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization CUDA kernel in Apex is not supported.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Compatibility
|
||||
|
||||
Atlas 800 (model 9010): CentOS 7.6/Ubuntu 18.04/BC-Linux 7.6/Debian 9.9/Debian 10/openEuler 20.03 LTS
|
||||
|
||||
Atlas 800 (model 9000): CentOS 7.6/EulerOS 2.8/Kylin v10/BC-Linux 7.6/openEuler 20.03 LTS
|
||||
|
||||
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 580 B |