Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f880a3241 | ||
|
|
829faa9699 | ||
|
|
7bc7563494 | ||
|
|
845cc94af2 | ||
|
|
51f24d37ee | ||
|
|
f64355d480 | ||
|
|
830fb4c643 | ||
|
|
3d8f28aa71 |
@@ -24,14 +24,11 @@ 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依赖库
|
||||
# Ascend配套软件
|
||||
|
||||
|
||||
依赖库安装:
|
||||
|
||||
```python3
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
| AscendPyTorch版本 | CANN版本 |
|
||||
| :------------ | :----------- |
|
||||
| 2.0.2 | CANN 5.0.2 |
|
||||
|
||||
|
||||
# 使用方式 --生成全量代码并编译
|
||||
@@ -63,6 +60,16 @@ bash gen.sh
|
||||
|
||||
会在pytorch/pytorch/目录中生成npu适配全量代码
|
||||
|
||||
|
||||
## python依赖库
|
||||
|
||||
进入到pytorch/pytorch/目录,依赖库安装:
|
||||
|
||||
```python3
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## 编译torch的二进制包
|
||||
|
||||
进入到pytorch/pytorch/目录,执行
|
||||
|
||||
@@ -445,7 +445,7 @@ if __name__ == '__main__':
|
||||
基于NPU芯片的架构特性,模型运算会涉及到混合精度,即混合使用float16和float32数据类型的应用场景。使用float16代替float32有如下好处:
|
||||
|
||||
- 对于中间变量的内存占用更少,节省内存的使用。
|
||||
- 因内存使用会减少,所以数据传出的时间也会减少。
|
||||
- 因内存使用会减少,所以数据传出的时间也会相应减少。
|
||||
- float16的计算单元可以提供更快的计算性能。
|
||||
|
||||
但是,混合精度训练受限于float16表达的精度范围,单纯将float32转换成float16会影响训练收敛情况,为了保证部分计算使用float16来进行加速的同时能保证训练收敛,这里采用混合精度模块Apex来达到以上效果。混合精度模块Apex是一个集优化性能、精度收敛于一身的综合优化库。
|
||||
@@ -465,12 +465,12 @@ if __name__ == '__main__':
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0278765773_row1571763813334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p4502732153412"><a name="zh-cn_topic_0278765773_p4502732153412"></a><a name="zh-cn_topic_0278765773_p4502732153412"></a>O1配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p640053920348"><a name="zh-cn_topic_0278765773_p640053920348"></a><a name="zh-cn_topic_0278765773_p640053920348"></a>Conv, Matmul等使用<span>float16</span>计算,其他如Softmax、BN使用<span>float32</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p640053920348"><a name="zh-cn_topic_0278765773_p640053920348"></a><a name="zh-cn_topic_0278765773_p640053920348"></a>Conv, Matmul等使用float16计算,其他如Softmax、BN使用float32。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0278765773_row3717173817336"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p11503103210344"><a name="zh-cn_topic_0278765773_p11503103210344"></a><a name="zh-cn_topic_0278765773_p11503103210344"></a>O2配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p164001639143419"><a name="zh-cn_topic_0278765773_p164001639143419"></a><a name="zh-cn_topic_0278765773_p164001639143419"></a>BN使用<span>float32</span>,其他绝大部分使用<span>float16</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p164001639143419"><a name="zh-cn_topic_0278765773_p164001639143419"></a><a name="zh-cn_topic_0278765773_p164001639143419"></a>BN使用float32,其他绝大部分使用float16。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0278765773_row14717193815334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p1950318328349"><a name="zh-cn_topic_0278765773_p1950318328349"></a><a name="zh-cn_topic_0278765773_p1950318328349"></a>静态Loss Scale功能</p>
|
||||
@@ -540,7 +540,6 @@ if __name__ == '__main__':
|
||||
apt-get install bzip2
|
||||
```
|
||||
|
||||
|
||||
4. 编译安装gcc。
|
||||
1. 进入gcc-7.3.0.tar.gz源码包所在目录,解压源码包,命令为:
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -14,7 +14,7 @@
|
||||
- [安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)
|
||||
<h2 id="简介.md">简介</h2>
|
||||
|
||||
用户在准备相关环境进行PyTorch模型的移植及训练时,可以选择在训练服务器中手动编译安装PyTorch框架相关模块,或直接获取Ascend Hub镜像中心提供的基础镜像(镜像中已安装PyTorch模块和混合精度模块),进行模型的移植与训练。
|
||||
用户在准备相关环境进行基于PyTorch框架模型的开发、运行时,可以选择在服务器中手动编译安装PyTorch框架相关模块,或直接获取Ascend Hub镜像中心提供的基础镜像(镜像中已安装PyTorch模块和混合精度模块),进行模型的开发、运行。
|
||||
|
||||
**图 1** 环境准备流程图<a name="zh-cn_topic_0000001119176876_fig1938918396117"></a>
|
||||

|
||||
@@ -118,7 +118,6 @@
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
|
||||
> **说明:**
|
||||
>受网络波动影响,源码获取时间可能较长,下载过程中请耐心等待。 下载完成之后若没有报错,即生成了PyTorch及其依赖的第三方代码。
|
||||
|
||||
@@ -141,7 +140,6 @@
|
||||
|
||||
生成的二进制包在当前的dist目录下,即“pytorch/pytorch/dist”文件夹目录下。
|
||||
|
||||
|
||||
5. <a name="zh-cn_topic_0000001152776301_li49671667141"></a>安装PyTorch。
|
||||
|
||||
进入“pytorch/pytorch/dist“文件夹目录,执行如下命令安装。
|
||||
@@ -159,7 +157,7 @@
|
||||
|
||||
<h2 id="配置环境变量.md">配置环境变量</h2>
|
||||
|
||||
安装完软件包后,需要配置环境变量才能正常使用昇腾PyTorch。建议构建启动脚本,例如构建set\_env.sh脚本,使用source set\_env.sh配置当前窗口的环境变量。set\_env.sh脚本内容如下(以root用户安装,安装路径为默认路径为例)。
|
||||
安装完软件包后,需要配置环境变量才能正常使用昇腾PyTorch。建议构建启动脚本,例如构建set\_env.sh脚本,使用source set\_env.sh配置当前窗口的环境变量。set\_env.sh脚本内容如下(以root用户安装,,安装路径为默认路径,python版本为3.7.5为例,用户可根据软件包实际安装路径修改配置项。)。
|
||||
|
||||
```
|
||||
cpu_type=$(echo $HOSTTYPE)
|
||||
@@ -341,7 +339,6 @@ export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请
|
||||
cd ..
|
||||
```
|
||||
|
||||
|
||||
> **说明:**
|
||||
>受网络波动影响,源码获取时间可能较长,下载过程中请耐心等待。
|
||||
|
||||
@@ -364,7 +361,6 @@ export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请
|
||||
|
||||
生成的二进制包在当前的dist目录下,即“apex/apex/dist”文件夹目录下。
|
||||
|
||||
|
||||
4. <a name="zh-cn_topic_0000001106176190_li425495374416"></a>安装apex。
|
||||
|
||||
进入“apex/apex/dist“文件夹目录,执行如下命令安装。
|
||||
@@ -391,7 +387,7 @@ export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请
|
||||
|
||||
## 前提条件<a name="zh-cn_topic_0000001118701830_zh-cn_topic_0275872734_section108914373254"></a>
|
||||
|
||||
- 已完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南》。
|
||||
- 已准备好相应硬件环境驱动和固件的安装,请参见各硬件产品[“驱动和固件安装升级指南”](https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)。需要在硬件设备上安装与CANN版本配套的固件与驱动。
|
||||
- 宿主机上已安装Docker。
|
||||
|
||||
## 获取并使用镜像<a name="zh-cn_topic_0000001118701830_section108941734162613"></a>
|
||||
@@ -497,7 +493,6 @@ CMake版本升级为3.12.1的方法
|
||||
apt-get install bzip2
|
||||
```
|
||||
|
||||
|
||||
4. 编译安装gcc。
|
||||
1. 进入gcc-7.3.0.tar.gz源码包所在目录,解压源码包,命令为:
|
||||
|
||||
@@ -561,7 +556,7 @@ CMake版本升级为3.12.1的方法
|
||||
|
||||
安装“torch-\*.whl”时,提示"ERROR:torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible"。
|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001105856364_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -18,7 +18,6 @@
|
||||
- [pip3.7 install torchvision安装失败](#pip3-7-install-torchvision安装失败.md)
|
||||
- [安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)
|
||||
- [如何查看测试的运行日志](#如何查看测试的运行日志.md)
|
||||
- [测试运行输出的NPU错误码是什么意思,有无对应的含义解释?](#测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md)
|
||||
- [为什么我实现的“自定义TBE算子”无法调用到?](#为什么我实现的-自定义TBE算子-无法调用到.md)
|
||||
- [如何确定“TBE算子”是否被“PyTorch适配”正确调用](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)
|
||||
- [PyTorch编译失败,提示“error: ld returned 1 exit status”](#PyTorch编译失败-提示-error-ld-returned-1-exit-status.md)
|
||||
@@ -30,7 +29,7 @@
|
||||
|
||||
## 概述<a name="zh-cn_topic_0000001125558589_section7405182695312"></a>
|
||||
|
||||
为了实现PyTorch深度学习框架在昇腾AI处理器上运行,需要将框架算子用TBE自定义开发。用户通过完成TBE自定义算子适配PyTorch框架,实现PyTorch框架中算子在昇腾AI处理器上运行。
|
||||
为了实现PyTorch深度学习框架在昇腾AI处理器上运行,需要将框架算子用TBE自定义开发。
|
||||
|
||||
<h2 id="算子开发流程.md">算子开发流程</h2>
|
||||
|
||||
@@ -234,7 +233,6 @@ git clone https://gitee.com/ascend/pytorch-develop.git --deepth=1
|
||||
- func:适配算子名称(输入参数信息) -> 返回类型
|
||||
```
|
||||
|
||||
|
||||
3. 修改native\_functions.yaml文件,添加实现该算子相关函数的分发描述。
|
||||
|
||||
yaml 文件编写规范:
|
||||
@@ -253,7 +251,6 @@ git clone https://gitee.com/ascend/pytorch-develop.git --deepth=1
|
||||
NPU: NPU_Adapt_Fun_Name
|
||||
```
|
||||
|
||||
|
||||
> **说明:**
|
||||
>NPU\_Adapt\_Fun\_Name的格式为 :
|
||||
>- 如果原Fun\_Name无"\_"后缀,则格式:Fun\_Name + "\_" + "npu",如:add --\> add\_npu。
|
||||
@@ -656,7 +653,7 @@ git clone https://gitee.com/ascend/pytorch-develop.git --deepth=1
|
||||
format_list = [0, 3, 29]
|
||||
shape_format = [
|
||||
[np.float32, i, [5, 256]] for i in format_list
|
||||
]
|
||||
]
|
||||
self.add_result(shape_format)
|
||||
|
||||
instantiate_device_type_tests(TestAdd, globals(), except_for="cpu")
|
||||
@@ -686,8 +683,6 @@ git clone https://gitee.com/ascend/pytorch-develop.git --deepth=1
|
||||
|
||||
- **[如何查看测试的运行日志](#如何查看测试的运行日志.md)**
|
||||
|
||||
- **[测试运行输出的NPU错误码是什么意思,有无对应的含义解释?](#测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md)**
|
||||
|
||||
- **[为什么我实现的“自定义TBE算子”无法调用到?](#为什么我实现的-自定义TBE算子-无法调用到.md)**
|
||||
|
||||
- **[如何确定“TBE算子”是否被“PyTorch适配”正确调用](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)**
|
||||
@@ -739,7 +734,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
安装“torch-\*.whl”时,提示"ERROR:torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible"。
|
||||
|
||||

|
||||

|
||||
|
||||
但实际安装成功
|
||||
|
||||
@@ -772,10 +767,6 @@ pip3.7 install torchvision --no-deps
|
||||
```
|
||||
|
||||
|
||||
<h2 id="测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md">测试运行输出的NPU错误码是什么意思,有无对应的含义解释?</h2>
|
||||
|
||||
参考“[错误码定义](https://support.huaweicloud.com/adevg-A300_3000_3010/atlasdevelopment_01_0256.html)”。
|
||||
|
||||
<h2 id="为什么我实现的-自定义TBE算子-无法调用到.md">为什么我实现的“自定义TBE算子”无法调用到?</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0000001125736795_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
@@ -802,7 +793,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
"pytorch/aten/src/ATen/native/npu/AddKernelNpu.cpp"
|
||||
|
||||

|
||||

|
||||
|
||||
2. 完成上两步的编译、安装,调用“python3.7 test\_add.py”进行测试。
|
||||
|
||||
@@ -848,7 +839,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
可以看到相应的算子\*.py源码文件均为“只读”,即此时不可编辑。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 修改算子\*.py源码文件属性,增加“可写”权限。
|
||||
|
||||
@@ -857,7 +848,7 @@ pip3.7 install torchvision --no-deps
|
||||
ll
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
3. 打开算子\*.py源码文件,增加日志,保存退出。
|
||||
|
||||
@@ -865,7 +856,7 @@ pip3.7 install torchvision --no-deps
|
||||
vi zn_2_nchw.py
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
上面例子只加了个标识,实际调测时,可以增加打印输入参数信息。
|
||||
|
||||
@@ -877,7 +868,7 @@ pip3.7 install torchvision --no-deps
|
||||
sudo chmod -w zn_2_nchw.py
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
<h2 id="PyTorch编译失败-提示-error-ld-returned-1-exit-status.md">PyTorch编译失败,提示“error: ld returned 1 exit status”</h2>
|
||||
@@ -886,13 +877,13 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
PyTorch编译失败,提示“ error: ld returned 1 exit status”。
|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125315885_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
通过日志分析,大概原因为XxxxKernelNpu.cpp中实现的适配函数,与PyTorch框架算子要求的分发实现接口参数不匹配。在上面的例子中,是“binary\_cross\_entropy\_npu”,打开对应的XxxxKernelNpu.cpp文件,找到相应的适配函数。
|
||||
|
||||

|
||||

|
||||
|
||||
可以看出实现中,最后一个参数是"int" ,与要求的“long”不匹配。
|
||||
|
||||
@@ -906,15 +897,15 @@ PyTorch编译失败,提示“ error: ld returned 1 exit status”。
|
||||
|
||||
PyTorch编译失败,提示“error: call of overload ....”。
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125641113_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
通过日志分析,错误出在XxxxKernelNpu.cpp中30行位置,NPUAttrDesc的参数不合法。在上面的例子中,是“binary\_cross\_entropy\_attr”,打开对应的XxxxKernelNpu.cpp文件,找到相应的适配函数。
|
||||
|
||||

|
||||

|
||||
|
||||
可以看出实现中,NPUAttrDesc的入参,第二个参数是"int" ,与NPUAttrDesc定义不匹配。
|
||||
|
||||
|
||||
|
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: 44 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 |
@@ -37,6 +37,8 @@
|
||||
- [调测过程](#调测过程-4.md)
|
||||
- [总体思路](#总体思路-5.md)
|
||||
- [精度调优方法](#精度调优方法.md)
|
||||
- [单算子溢出检测](#单算子溢出检测.md)
|
||||
- [整网调测](#整网调测.md)
|
||||
- [模型保存与转换](#模型保存与转换.md)
|
||||
- [简介](#简介.md)
|
||||
- [模型保存](#模型保存.md)
|
||||
@@ -59,6 +61,7 @@
|
||||
- [常用环境变量说明](#常用环境变量说明.md)
|
||||
- [dump op方法](#dump-op方法.md)
|
||||
- [安装7.3.0版本gcc](#安装7-3-0版本gcc.md)
|
||||
- [编译安装hdf5](#编译安装hdf5.md)
|
||||
- [FAQ](#FAQ.md)
|
||||
- [软件安装常见问题](#软件安装常见问题.md)
|
||||
- [pip3.7 install Pillow==5.3.0安装失败](#pip3-7-install-Pillow-5-3-0安装失败.md)
|
||||
@@ -70,7 +73,7 @@
|
||||
- [在模型运行时遇到报错“RuntimeError: Initialize.”](#在模型运行时遇到报错-RuntimeError-Initialize.md)
|
||||
- [在模型运行时遇到报错“TVM/te/cce error.”](#在模型运行时遇到报错-TVM-te-cce-error.md)
|
||||
- [在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed.md)
|
||||
- [在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”1](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-1.md)
|
||||
- [在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-7.md)
|
||||
- [在模型运行时将多任务下发关闭\(export TASK\_QUEUE\_ENABLE=0\)后仍然遇到报错“HelpACLExecute.”](#在模型运行时将多任务下发关闭(export-TASK_QUEUE_ENABLE-0)后仍然遇到报错-HelpACLExecute.md)
|
||||
- [在模型运行时遇到报错“55056 GetInputConstDataOut: ErrorNo: -1\(failed\)”](#在模型运行时遇到报错-55056-GetInputConstDataOut-ErrorNo--1(failed).md)
|
||||
- [模型调测常见问题](#模型调测常见问题.md)
|
||||
@@ -152,7 +155,7 @@
|
||||
</tr>
|
||||
<tr id="row9883113014287"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p8883203017280"><a name="p8883203017280"></a><a name="p8883203017280"></a>算子开发</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p158831830192814"><a name="p158831830192814"></a><a name="p158831830192814"></a>详情请参见<span id="ph144957513112"><a name="ph144957513112"></a><a name="ph144957513112"></a><span id="ph07771712101117"><a name="ph07771712101117"></a><a name="ph07771712101117"></a>《PyTorch算子开发指南》</span></span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p158831830192814"><a name="p158831830192814"></a><a name="p158831830192814"></a>详情请参见<span id="ph144957513112"><a name="ph144957513112"></a><a name="ph144957513112"></a><span id="ph45906272222"><a name="ph45906272222"></a><a name="ph45906272222"></a>《PyTorch算子开发指南》</span></span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row2056653212812"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p1656743213814"><a name="p1656743213814"></a><a name="p1656743213814"></a>环境准备</p>
|
||||
@@ -172,7 +175,7 @@
|
||||
</tr>
|
||||
<tr id="row1658912015291"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p195901920192910"><a name="p195901920192910"></a><a name="p195901920192910"></a>错误分析</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p95904208295"><a name="p95904208295"></a><a name="p95904208295"></a>详情请参见<span id="ph92061657112415"><a name="ph92061657112415"></a><a name="ph92061657112415"></a>《CANN 日志参考》</span>和<span id="ph4109111816191"><a name="ph4109111816191"></a><a name="ph4109111816191"></a>《CANN 开发辅助工具指南》</span>中“AI Core Error分析工具使用指南”章节。</p>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p95904208295"><a name="p95904208295"></a><a name="p95904208295"></a>详情请参见<span id="ph7924185091616"><a name="ph7924185091616"></a><a name="ph7924185091616"></a>《CANN 日志参考》</span>和<span id="ph1572317171516"><a name="ph1572317171516"></a><a name="ph1572317171516"></a>《CANN 开发辅助工具指南》</span>中“AI Core Error分析工具使用指南”章节。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13191151664310"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p219216162433"><a name="p219216162433"></a><a name="p219216162433"></a>性能调优和分析</p>
|
||||
@@ -187,12 +190,12 @@
|
||||
</tr>
|
||||
<tr id="row7630202112430"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p1263012210438"><a name="p1263012210438"></a><a name="p1263012210438"></a>模型保存与转换</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p12631521104319"><a name="p12631521104319"></a><a name="p12631521104319"></a>详情请参见<a href="#模型保存与转换.md">模型保存与转换</a>和<span id="ph1834334902411"><a name="ph1834334902411"></a><a name="ph1834334902411"></a><span id="ph13354922101910"><a name="ph13354922101910"></a><a name="ph13354922101910"></a>《CANN 开发辅助工具指南》</span></span>中“ATC工具使用指南”章节。</p>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p12631521104319"><a name="p12631521104319"></a><a name="p12631521104319"></a>详情请参见<a href="#模型保存与转换.md">模型保存与转换</a>和<span id="ph98735134233"><a name="ph98735134233"></a><a name="ph98735134233"></a>《CANN 开发辅助工具指南》</span>中“ATC工具使用指南”章节。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row196272410438"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p176218241431"><a name="p176218241431"></a><a name="p176218241431"></a>应用软件开发</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p1962142434317"><a name="p1962142434317"></a><a name="p1962142434317"></a>详情请参见<span id="ph10403111142311"><a name="ph10403111142311"></a><a name="ph10403111142311"></a><span id="ph16725185971512"><a name="ph16725185971512"></a><a name="ph16725185971512"></a>《CANN 应用软件开发指南(C&C++, 推理)》</span></span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="71.82%" headers="mcps1.2.3.1.2 "><p id="p1962142434317"><a name="p1962142434317"></a><a name="p1962142434317"></a>详情请参见<span id="ph1062525151815"><a name="ph1062525151815"></a><a name="ph1062525151815"></a>《CANN 应用软件开发指南(C&C++, 推理)》</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17586759102515"><td class="cellrowborder" valign="top" width="28.18%" headers="mcps1.2.3.1.1 "><p id="p6586155952510"><a name="p6586155952510"></a><a name="p6586155952510"></a>FAQ</p>
|
||||
@@ -225,7 +228,7 @@
|
||||
|
||||
<h2 id="配置环境变量.md">配置环境变量</h2>
|
||||
|
||||
安装完软件包后,需要配置环境变量才能正常使用昇腾PyTorch。建议构建启动脚本,例如构建set\_env.sh脚本,使用source set\_env.sh配置当前窗口的环境变量。set\_env.sh脚本内容如下(以root用户安装,安装路径为默认路径为例)。
|
||||
安装完软件包后,需要配置环境变量才能正常使用昇腾PyTorch。建议构建启动脚本,例如构建set\_env.sh脚本,使用source set\_env.sh配置当前窗口的环境变量。set\_env.sh脚本内容如下(以root用户安装,安装路径为默认路径,python版本为3.7.5为例,用户可根据软件包实际安装路径修改配置项。)。
|
||||
|
||||
```
|
||||
cpu_type=$(echo $HOSTTYPE)
|
||||
@@ -291,18 +294,18 @@ export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_row6882121917329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p688241953218"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p688241953218"></a><a name="zh-cn_topic_0000001134654416_zh-cn_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="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"></a><span>动态库的查找路径,</span>参考上述举例配置。</p>
|
||||
<p id="zh-cn_topic_0000001134654416_p1292181892120"><a name="zh-cn_topic_0000001134654416_p1292181892120"></a><a name="zh-cn_topic_0000001134654416_p1292181892120"></a>若训练所在系统环境需要升级gcc(例如CentOS、Debian和BClinux系统),则<span class="parmname" id="zh-cn_topic_0000001134654416_parmname795020446318"><a name="zh-cn_topic_0000001134654416_parmname795020446318"></a><a name="zh-cn_topic_0000001134654416_parmname795020446318"></a>“LD_LIBRARY_PATH”</span>配置项处动态库查找路径需要添加<span class="filepath" id="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"></a>“${install_path}/lib64”</span>,其中<span class="filepath" id="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"></a>“{install_path}”</span>为gcc升级安装路径。请参见<a href="#zh-cn_topic_0000001181522175.md#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li9745165315131">5</a>。</p>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1888291915322"></a>动态库的查找路径,参考上述举例配置。</p>
|
||||
<p id="zh-cn_topic_0000001134654416_p1292181892120"><a name="zh-cn_topic_0000001134654416_p1292181892120"></a><a name="zh-cn_topic_0000001134654416_p1292181892120"></a>若训练所在系统环境需要升级gcc(例如CentOS、Debian和BClinux系统),则<span class="parmname" id="zh-cn_topic_0000001134654416_parmname795020446318"><a name="zh-cn_topic_0000001134654416_parmname795020446318"></a><a name="zh-cn_topic_0000001134654416_parmname795020446318"></a>“LD_LIBRARY_PATH”</span>配置项处动态库查找路径需要添加<span class="filepath" id="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath115819811512"></a>“${install_path}/lib64”</span>,其中<span class="filepath" id="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0256062644_filepath195951574421"></a>“{install_path}”</span>为gcc升级安装路径。请参见<a href="#安装7-3-0版本gcc.md#zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li9745165315131">5</a>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_row16194175523010"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p16195185523019"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p16195185523019"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p16195185523019"></a>PYTHONPATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"></a><span>Python搜索路径,</span>参考上述举例配置。</p>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p19637083322"></a>Python搜索路径,参考上述举例配置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_row2954102119329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p195452113218"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p195452113218"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p195452113218"></a>PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"></a><span>可执行程序的查找路径,</span>参考上述举例配置。</p>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p964914893211"></a>可执行程序的查找路径,参考上述举例配置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_row58592816294"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1886016892913"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1886016892913"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p1886016892913"></a>ASCEND_OPP_PATH</p>
|
||||
@@ -328,7 +331,7 @@ export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请
|
||||
<tr id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_row1680820246202"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p4809112415207"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p4809112415207"></a><a name="zh-cn_topic_0000001134654416_zh-cn_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="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p952814428206"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p952814428206"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p952814428206"></a>配置在使用HCCL时是否开启通信白名单。</p>
|
||||
<a name="zh-cn_topic_0000001134654416_ul928845132310"></a><a name="zh-cn_topic_0000001134654416_ul928845132310"></a><ul id="zh-cn_topic_0000001134654416_ul928845132310"><li>0:开启白名单,无需校验HCCL通信白名单。</li><li>1:关闭白名单,需校验HCCL通信白名单。</li></ul>
|
||||
<a name="zh-cn_topic_0000001134654416_ul928845132310"></a><a name="zh-cn_topic_0000001134654416_ul928845132310"></a><ul id="zh-cn_topic_0000001134654416_ul928845132310"><li>0:开启白名单</li><li>1:关闭白名单</li></ul>
|
||||
<p id="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p5809162416201"><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p5809162416201"></a><a name="zh-cn_topic_0000001134654416_zh-cn_topic_0000001152616261_p5809162416201"></a>缺省值为0,默认开启白名单。</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -680,51 +683,78 @@ Ascend平台提供了脚本转换工具使用户能通过命令行方式将训
|
||||
|
||||
## 参数说明<a name="zh-cn_topic_0000001086713630_section21951346163910"></a>
|
||||
|
||||
**表 1** 参数说明
|
||||
1.
|
||||
|
||||
**表 1** 参数说明
|
||||
|
||||
<a name="zh-cn_topic_0000001086713630_table1581171912407"></a>
|
||||
<table><thead align="left"><tr id="zh-cn_topic_0000001086713630_row175811919124014"><th class="cellrowborder" valign="top" width="22.35%" id="mcps1.2.4.1.1"><p id="zh-cn_topic_0000001086713630_p155823194404"><a name="zh-cn_topic_0000001086713630_p155823194404"></a><a name="zh-cn_topic_0000001086713630_p155823194404"></a>参数</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="54.75%" id="mcps1.2.4.1.2"><p id="zh-cn_topic_0000001086713630_p105820192400"><a name="zh-cn_topic_0000001086713630_p105820192400"></a><a name="zh-cn_topic_0000001086713630_p105820192400"></a>参数说明</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="22.900000000000002%" id="mcps1.2.4.1.3"><p id="zh-cn_topic_0000001086713630_p6580427104516"><a name="zh-cn_topic_0000001086713630_p6580427104516"></a><a name="zh-cn_topic_0000001086713630_p6580427104516"></a>取值示例</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0000001086713630_row1582131914407"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p19582151918409"><a name="zh-cn_topic_0000001086713630_p19582151918409"></a><a name="zh-cn_topic_0000001086713630_p19582151918409"></a>-i</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p2473202124113"><a name="zh-cn_topic_0000001086713630_p2473202124113"></a><a name="zh-cn_topic_0000001086713630_p2473202124113"></a>--input</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul1242295411339"></a><a name="zh-cn_topic_0000001086713630_ul1242295411339"></a><ul id="zh-cn_topic_0000001086713630_ul1242295411339"><li>要进行转换的原始脚本文件所在文件夹路径或文件路径。</li><li>必选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><a name="zh-cn_topic_0000001086713630_ul1643544143415"></a><a name="zh-cn_topic_0000001086713630_ul1643544143415"></a><ul id="zh-cn_topic_0000001086713630_ul1643544143415"><li>/home/username/fmktransplt</li><li>/home/username/fmktransplt.py</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1742052304118"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p442092316415"><a name="zh-cn_topic_0000001086713630_p442092316415"></a><a name="zh-cn_topic_0000001086713630_p442092316415"></a>-o</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p16543329134117"><a name="zh-cn_topic_0000001086713630_p16543329134117"></a><a name="zh-cn_topic_0000001086713630_p16543329134117"></a>--output</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul1363116594714"></a><a name="zh-cn_topic_0000001086713630_ul1363116594714"></a><ul id="zh-cn_topic_0000001086713630_ul1363116594714"><li>脚本转换结果文件输出路径。会在该路径下输出带有msft后缀的文件夹。</li><li>必选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p2478319143616"><a name="zh-cn_topic_0000001086713630_p2478319143616"></a><a name="zh-cn_topic_0000001086713630_p2478319143616"></a>/home/username/fmktransplt_output</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row5405851153019"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p164051151163010"><a name="zh-cn_topic_0000001086713630_p164051151163010"></a><a name="zh-cn_topic_0000001086713630_p164051151163010"></a>-r</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p11383956183014"><a name="zh-cn_topic_0000001086713630_p11383956183014"></a><a name="zh-cn_topic_0000001086713630_p11383956183014"></a>--rule</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul4776121015816"></a><a name="zh-cn_topic_0000001086713630_ul4776121015816"></a><ul id="zh-cn_topic_0000001086713630_ul4776121015816"><li>用户自定义通用转换规则的json文件路径,主要分为:函数参数修改、函数名称修改和模块名称修改三部分。</li><li>可选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p6273113412368"><a name="zh-cn_topic_0000001086713630_p6273113412368"></a><a name="zh-cn_topic_0000001086713630_p6273113412368"></a>/home/username/fmktransplt_rule.json</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1355087145112"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p1801752706"><a name="zh-cn_topic_0000001086713630_p1801752706"></a><a name="zh-cn_topic_0000001086713630_p1801752706"></a>-s</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p011914159516"><a name="zh-cn_topic_0000001086713630_p011914159516"></a><a name="zh-cn_topic_0000001086713630_p011914159516"></a>--specify-device</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul186822151820"></a><a name="zh-cn_topic_0000001086713630_ul186822151820"></a><ul id="zh-cn_topic_0000001086713630_ul186822151820"><li>可以通过环境变量设置指定device作为高级特性,但有可能导致原本脚本中分布式功能失效。</li><li>可选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p185502785114"><a name="zh-cn_topic_0000001086713630_p185502785114"></a><a name="zh-cn_topic_0000001086713630_p185502785114"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1914883514326"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p51490353324"><a name="zh-cn_topic_0000001086713630_p51490353324"></a><a name="zh-cn_topic_0000001086713630_p51490353324"></a>-sim</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p5549113123714"><a name="zh-cn_topic_0000001086713630_p5549113123714"></a><a name="zh-cn_topic_0000001086713630_p5549113123714"></a>--similar</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul856518554400"></a><a name="zh-cn_topic_0000001086713630_ul856518554400"></a><ul id="zh-cn_topic_0000001086713630_ul856518554400"><li>用功能相似的API替换某些不支持的API,但有可能导致准确性和性能下降。</li><li>可选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p13149193573212"><a name="zh-cn_topic_0000001086713630_p13149193573212"></a><a name="zh-cn_topic_0000001086713630_p13149193573212"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row311811519515"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p1755018717511"><a name="zh-cn_topic_0000001086713630_p1755018717511"></a><a name="zh-cn_topic_0000001086713630_p1755018717511"></a>distributed</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001086713630_p27033264208"><a name="zh-cn_topic_0000001086713630_p27033264208"></a><a name="zh-cn_topic_0000001086713630_p27033264208"></a>将GPU单卡脚本转换为NPU多卡脚本,仅支持使用torch.utils.data.DataLoader方式加载数据的场景,指定此参数时,才可以指定以下两个参数。</p>
|
||||
<a name="zh-cn_topic_0000001086713630_ul94321522131015"></a><a name="zh-cn_topic_0000001086713630_ul94321522131015"></a><ul id="zh-cn_topic_0000001086713630_ul94321522131015"><li>-m,--main:训练脚本的入口python文件,必选。</li><li>-t,--target model:目标模型变量名,默认为'model',可选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p011961519515"><a name="zh-cn_topic_0000001086713630_p011961519515"></a><a name="zh-cn_topic_0000001086713630_p011961519515"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1736213644115"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p1036312363411"><a name="zh-cn_topic_0000001086713630_p1036312363411"></a><a name="zh-cn_topic_0000001086713630_p1036312363411"></a>-h</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p176714017418"><a name="zh-cn_topic_0000001086713630_p176714017418"></a><a name="zh-cn_topic_0000001086713630_p176714017418"></a>--help</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001086713630_p1373193411818"><a name="zh-cn_topic_0000001086713630_p1373193411818"></a><a name="zh-cn_topic_0000001086713630_p1373193411818"></a>显示帮助信息。</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p358017279458"><a name="zh-cn_topic_0000001086713630_p358017279458"></a><a name="zh-cn_topic_0000001086713630_p358017279458"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a name="zh-cn_topic_0000001086713630_table1581171912407"></a>
|
||||
<table><thead align="left"><tr id="zh-cn_topic_0000001086713630_row175811919124014"><th class="cellrowborder" valign="top" width="22.35%" id="mcps1.2.4.1.1"><p id="zh-cn_topic_0000001086713630_p155823194404"><a name="zh-cn_topic_0000001086713630_p155823194404"></a><a name="zh-cn_topic_0000001086713630_p155823194404"></a>参数</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="54.75%" id="mcps1.2.4.1.2"><p id="zh-cn_topic_0000001086713630_p105820192400"><a name="zh-cn_topic_0000001086713630_p105820192400"></a><a name="zh-cn_topic_0000001086713630_p105820192400"></a>参数说明</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="22.900000000000002%" id="mcps1.2.4.1.3"><p id="zh-cn_topic_0000001086713630_p6580427104516"><a name="zh-cn_topic_0000001086713630_p6580427104516"></a><a name="zh-cn_topic_0000001086713630_p6580427104516"></a>取值示例</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0000001086713630_row1582131914407"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p19582151918409"><a name="zh-cn_topic_0000001086713630_p19582151918409"></a><a name="zh-cn_topic_0000001086713630_p19582151918409"></a>-i</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p2473202124113"><a name="zh-cn_topic_0000001086713630_p2473202124113"></a><a name="zh-cn_topic_0000001086713630_p2473202124113"></a>--input</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul1242295411339"></a><a name="zh-cn_topic_0000001086713630_ul1242295411339"></a><ul id="zh-cn_topic_0000001086713630_ul1242295411339"><li>要进行转换的原始脚本文件所在文件夹路径或文件路径。</li><li>必选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><a name="zh-cn_topic_0000001086713630_ul1643544143415"></a><a name="zh-cn_topic_0000001086713630_ul1643544143415"></a><ul id="zh-cn_topic_0000001086713630_ul1643544143415"><li>/home/username/fmktransplt</li><li>/home/username/fmktransplt.py</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1742052304118"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p442092316415"><a name="zh-cn_topic_0000001086713630_p442092316415"></a><a name="zh-cn_topic_0000001086713630_p442092316415"></a>-o</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p16543329134117"><a name="zh-cn_topic_0000001086713630_p16543329134117"></a><a name="zh-cn_topic_0000001086713630_p16543329134117"></a>--output</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul1363116594714"></a><a name="zh-cn_topic_0000001086713630_ul1363116594714"></a><ul id="zh-cn_topic_0000001086713630_ul1363116594714"><li>脚本转换结果文件输出路径。会在该路径下输出带有msft后缀的文件夹。</li><li>必选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p2478319143616"><a name="zh-cn_topic_0000001086713630_p2478319143616"></a><a name="zh-cn_topic_0000001086713630_p2478319143616"></a>/home/username/fmktransplt_output</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row5405851153019"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p164051151163010"><a name="zh-cn_topic_0000001086713630_p164051151163010"></a><a name="zh-cn_topic_0000001086713630_p164051151163010"></a>-r</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p11383956183014"><a name="zh-cn_topic_0000001086713630_p11383956183014"></a><a name="zh-cn_topic_0000001086713630_p11383956183014"></a>--rule</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><a name="zh-cn_topic_0000001086713630_ul4776121015816"></a><a name="zh-cn_topic_0000001086713630_ul4776121015816"></a><ul id="zh-cn_topic_0000001086713630_ul4776121015816"><li>用户自定义通用转换规则的json文件路径,主要分为:函数参数修改、函数名称修改和模块名称修改三部分。</li><li>可选。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p6273113412368"><a name="zh-cn_topic_0000001086713630_p6273113412368"></a><a name="zh-cn_topic_0000001086713630_p6273113412368"></a>/home/username/fmktransplt_rule.json</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row1736213644115"><td class="cellrowborder" valign="top" width="22.35%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001086713630_p1036312363411"><a name="zh-cn_topic_0000001086713630_p1036312363411"></a><a name="zh-cn_topic_0000001086713630_p1036312363411"></a>-h</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p176714017418"><a name="zh-cn_topic_0000001086713630_p176714017418"></a><a name="zh-cn_topic_0000001086713630_p176714017418"></a>--help</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="54.75%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001086713630_p1373193411818"><a name="zh-cn_topic_0000001086713630_p1373193411818"></a><a name="zh-cn_topic_0000001086713630_p1373193411818"></a>显示帮助信息。</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="22.900000000000002%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001086713630_p358017279458"><a name="zh-cn_topic_0000001086713630_p358017279458"></a><a name="zh-cn_topic_0000001086713630_p358017279458"></a>-</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## 自定义规则文件<a name="zh-cn_topic_0000001086713630_section1879318256392"></a>
|
||||
|
||||
@@ -813,7 +843,8 @@ Ascend平台提供了脚本转换工具使用户能通过命令行方式将训
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001086713630_row4677165715235"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001086713630_p2434071544"><a name="zh-cn_topic_0000001086713630_p2434071544"></a><a name="zh-cn_topic_0000001086713630_p2434071544"></a>parent_module</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001086713630_p443419713418"><a name="zh-cn_topic_0000001086713630_p443419713418"></a><a name="zh-cn_topic_0000001086713630_p443419713418"></a>父级模块名称</p>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001086713630_p571992311016"><a name="zh-cn_topic_0000001086713630_p571992311016"></a><a name="zh-cn_topic_0000001086713630_p571992311016"></a>父级模块全名</p>
|
||||
<p id="zh-cn_topic_0000001086713630_p1065614314599"><a name="zh-cn_topic_0000001086713630_p1065614314599"></a><a name="zh-cn_topic_0000001086713630_p1065614314599"></a>例如torch.cuda.amp,amp的父级模块全名为torch.cuda。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -830,20 +861,25 @@ Ascend平台提供了脚本转换工具使用户能通过命令行方式将训
|
||||
2. 执行脚本转换工具。
|
||||
|
||||
```
|
||||
python3 ms_fmk_transplt.py -i 原始脚本路径 -o 脚本转换结果输出路径 [-r 自定义规则json文件路径]
|
||||
python3 ms_fmk_transplt.py -i 原始脚本路径 -o 脚本转换结果输出路径 [-r 自定义规则json文件路径] [-s] [-sim] [distributed -m 训练脚本的入口文件 -t 目标模型变量名]
|
||||
```
|
||||
|
||||
> **说明:**
|
||||
>distributed及其参数-m、-t在语句最后指定。
|
||||
|
||||
3. 完成脚本转换。
|
||||
|
||||
<h2 id="结果解析.md">结果解析</h2>
|
||||
|
||||
脚本转换完成后,进入脚本转换结果输出路径查看结果文件。
|
||||
脚本转换完成后,进入脚本转换结果输出路径查看结果文件,以GPU单卡脚本转换为NPU多卡脚本为例。
|
||||
|
||||
```
|
||||
├── xxx_msft // 脚本转换结果输出目录,默认为原始脚本路径。xxx为原始脚本所在文件夹名称。
|
||||
│ ├── 生成脚本文件 // 与转换前的脚本文件目录结构一致。
|
||||
│ ├── msFmkTranspltlog.txt // 脚本转换过程日志文件。
|
||||
│ ├── unsupported_op.xlsx // 不支持算子列表文件。
|
||||
│ ├── change_list.csv // 修改记录文件。
|
||||
│ ├── run_distributed_npu.sh // 多卡启动shell脚本。
|
||||
```
|
||||
|
||||
<h2 id="手工迁移.md">手工迁移</h2>
|
||||
@@ -1119,7 +1155,7 @@ def main():
|
||||
基于NPU芯片的架构特性,会涉及到混合精度训练,即混合使用float16和float32数据类型的应用场景。使用float16代替float32有如下好处:
|
||||
|
||||
- 对于中间变量的内存占用更少,节省内存的使用。
|
||||
- 因内存使用会减少,所以数据传出的时间也会减半。
|
||||
- 因内存使用会减少,所以数据传出的时间也会相应减少。
|
||||
- float16的计算单元可以提供更快的计算性能。
|
||||
|
||||
但是,混合精度训练受限于float16表达的精度范围,单纯将float32转换成float16会影响训练收敛情况,为了保证部分计算使用float16来进行加速的同时能保证训练收敛,这里采用混合精度模块Apex来达到以上效果。混合精度模块Apex是一个集优化性能、精度收敛于一身的综合优化库。
|
||||
@@ -1144,12 +1180,12 @@ def main():
|
||||
</thead>
|
||||
<tbody><tr id="row1571763813334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="p4502732153412"><a name="p4502732153412"></a><a name="p4502732153412"></a>O1配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="p640053920348"><a name="p640053920348"></a><a name="p640053920348"></a>Conv,Matmal等使用<span>float16</span>计算,其他如Softmax、BN使用<span>float32</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="p640053920348"><a name="p640053920348"></a><a name="p640053920348"></a>Conv,Matmul等使用float16计算,其他如Softmax、BN使用float32。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row3717173817336"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="p11503103210344"><a name="p11503103210344"></a><a name="p11503103210344"></a>O2配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="p164001639143419"><a name="p164001639143419"></a><a name="p164001639143419"></a>除了BN使用<span>float32</span>外,其他绝大部分使用<span>float16</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="p164001639143419"><a name="p164001639143419"></a><a name="p164001639143419"></a>除了BN使用float32外,其他绝大部分使用float16。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row14717193815334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="p1950318328349"><a name="p1950318328349"></a><a name="p1950318328349"></a>静态Loss Scale功能</p>
|
||||
@@ -1234,12 +1270,12 @@ def main():
|
||||
**图 1** 远程登录控制台<a name="fig15869135420288"></a>
|
||||

|
||||
|
||||
2. 在虚拟界面工具栏中,单击启动项工具,弹出启动项配置界面,如[图2](#fig744814574243)。
|
||||
2. 在虚拟界面工具栏中,单击启动项工具,弹出启动项配置界面,如[图2](#fig744814574243)。
|
||||
|
||||
**图 2** 启动项工具<a name="fig744814574243"></a>
|
||||

|
||||
|
||||
3. 在启动项配置界面选择,选择“BIOS设置”,然后在虚拟界面工具栏中单击重启工具,重启服务器。
|
||||
3. 在启动项配置界面选择,选择“BIOS设置”,然后在虚拟界面工具栏中单击重启工具,重启服务器。
|
||||
4. 系统重启后进入BIOS配置界面,依次选择“Advanced”\>“Socket Configuration”,如[图3](#fig4546303814)所示。
|
||||
|
||||
**图 3** Socket Configuration<a name="fig4546303814"></a>
|
||||
@@ -1322,7 +1358,6 @@ def main():
|
||||
systemctl start cpupower
|
||||
```
|
||||
|
||||
|
||||
3. 设置CPU为performance模式。
|
||||
|
||||
```
|
||||
@@ -1342,12 +1377,12 @@ def main():
|
||||
**图 1** 远程登录控制台<a name="fig15869135420288"></a>
|
||||

|
||||
|
||||
2. 在虚拟界面工具栏中,单击启动项工具,弹出启动项配置界面,如[图2](#fig744814574243)。
|
||||
2. 在虚拟界面工具栏中,单击启动项工具,弹出启动项配置界面,如[图2](#fig744814574243)。
|
||||
|
||||
**图 2** 启动项工具<a name="fig744814574243"></a>
|
||||

|
||||
|
||||
3. 在启动项配置界面选择,选择“BIOS设置”,然后在虚拟界面工具栏中单击重启工具,重启服务器。
|
||||
3. 在启动项配置界面选择,选择“BIOS设置”,然后在虚拟界面工具栏中单击重启工具,重启服务器。
|
||||
4. 系统重启后进入BIOS配置界面,依次选择“Advanced”\>“ Performance Config”,如[图3](#fig4546303814)所示。
|
||||
|
||||
**图 3** Performance Config<a name="fig4546303814"></a>
|
||||
@@ -1420,7 +1455,10 @@ def main():
|
||||
|
||||
<h2 id="模型训练.md">模型训练</h2>
|
||||
|
||||
训练脚本迁移完成后,需要参见[配置环境变量](#配置环境变量.md)设置环境变量,然后执行**python3.7** _xxx_进行模型训练。具体样例请参考[脚本执行](#脚本执行.md)。
|
||||
训练脚本迁移完成后,需要参见[配置环境变量](#配置环境变量.md)设置环境变量,然后执行**python3** _xxx_进行模型训练。具体样例请参考[脚本执行](#脚本执行.md)。
|
||||
|
||||
> **说明:**
|
||||
>执行“python3 xxx“命令时,须将python3软链接到与当前pytorch适配版本的python安装路径。
|
||||
|
||||
<h2 id="性能调优和分析.md">性能调优和分析</h2>
|
||||
|
||||
@@ -1461,23 +1499,51 @@ def main():
|
||||
|
||||
## Profiling数据采集<a name="section141471611314"></a>
|
||||
|
||||
当吞吐量指标不达标时,需要通过采集训练过程中的profiling数据,分析哪个环节、哪个算子导致的性能消耗。请参见以下步骤进行profiling数据的获取。
|
||||
当模型训练过程中吞吐量指标不达标时,可以通过采集训练过程中的profiling数据,分析哪个环节、哪个算子导致的性能消耗。Profiling数据采集分为PyTorch层面和CANN层面的采集,PyTorch层面采集的是PyTorch API的数据,CANN层面采集的是TBE算子的数据。
|
||||
|
||||
1. 获取chrome\_trace文件。使用profile接口对原始代码的loss计算和优化过程进行改造。
|
||||
请参见以下方式进行profiling数据的获取,并根据实际情况选择需要的数据采集方式。
|
||||
|
||||
- PyTorch层面Profiling数据采集。
|
||||
1. 获取chrome\_trace文件。
|
||||
|
||||
使用profile接口对原始代码的loss计算和优化过程进行改造。
|
||||
|
||||
```
|
||||
# 使用ascend-pytorch适配的profile接口,即可获得,推荐只运行一个step
|
||||
with torch.autograd.profiler.profile(use_npu=True) as prof:
|
||||
out = model(input_tensor)
|
||||
loss=loss_func(out)
|
||||
loss.backward()
|
||||
optimizer.zero_grad()
|
||||
optimizer.step()
|
||||
# 导出chrome_trace文件到指定路径
|
||||
output_path = '/home/HwHiAiUser/profile_data.json'
|
||||
prof.export_chrome_trace(output_path)
|
||||
```
|
||||
|
||||
2. 查看chrome\_trace文件。
|
||||
|
||||
chrome\_trace文件可以通过以下方式打开查看:在Chrome浏览器中输入“chrome://tracing“地址,然后将落盘文件拖到空白处即可打开文件内容,通过键盘W、A、S、D键,可以对profiler的结果进行缩放和移动。
|
||||
|
||||
|
||||
- CANN层面Profiling数据采集。
|
||||
1. 获取性能数据文件。
|
||||
|
||||
```
|
||||
profiler_result_path = "/home/profiling_data" # profiling 数据保存的文件夹,需提前手动创建,请根据实际指定。
|
||||
with torch.npu.profile(profiler_result_path) as prof:
|
||||
out = model(input_tensor)
|
||||
loss=loss_func(out)
|
||||
loss.backward()
|
||||
optimizer.zero_grad()
|
||||
optimizer.step()
|
||||
```
|
||||
|
||||
2. 解析性能数据文件。
|
||||
|
||||
请参见《CANN 开发辅助工具指南》中“Profiling工具使用指南(训练)”章节。
|
||||
|
||||
```
|
||||
# 使用ascend-pytorch适配的profile接口,即可获得,推荐只运行一个step
|
||||
with torch.autograd.profiler.profile(use_npu=True) as prof:
|
||||
out = model(input_tensor)
|
||||
loss=loss_func(out)
|
||||
loss.backward()
|
||||
optimizer.zero_grad()
|
||||
optimizer.step()
|
||||
# 导出chrome_trace文件到指定路径
|
||||
prof.export_chrome_trace(output_path)
|
||||
```
|
||||
|
||||
2. chrome\_trace文件可以通过以下方式打开查看:在Chrome浏览器中输入“chrome://tracing“地址,然后将落盘文件拖到空白处即可打开文件内容,通过键盘W、A、S、D键,可以对profiler的结果进行缩放和移动。
|
||||
|
||||
## 获取算子信息OP\_INFO<a name="section15654162853114"></a>
|
||||
|
||||
@@ -1541,7 +1607,7 @@ def main():
|
||||
5. 解析host侧日志会在当前目录下得到OPInfo信息ascend\_op\_info\_summary.txt。
|
||||
|
||||
```
|
||||
python3.7 get_ascend_op_info.py --host_log_folder $HOME/ascend/log/plog
|
||||
python3 get_ascend_op_info.py --host_log_folder $HOME/ascend/log/plog
|
||||
```
|
||||
|
||||
6. 分析TaskInfo中额外的task,尤其关注transdata。
|
||||
@@ -1675,7 +1741,6 @@ def main():
|
||||
|
||||
- 解决方案:改进算子精度或功能问题。
|
||||
|
||||
|
||||
2. <a name="li25281726103316"></a>loss计算错误。
|
||||
- 定位思路:由于Loss的特殊性和可以自定义,在判断Loss计算错误后建议dump网络中的loss的输入来测试而非随机同shape tensor,这样才能更好地复现证明。
|
||||
|
||||
@@ -1683,7 +1748,6 @@ def main():
|
||||
|
||||
- 解决方案:改进算子精度或功能问题(loss也是由算子构成)。
|
||||
|
||||
|
||||
3. 参数更新错误。
|
||||
|
||||
- 定位思路:在每个optim.step\(\)前对网络中的参数逐个打印其grad进行排查判断是哪个地方有较大嫌疑,然后构建单算子用例逐渐缩小错误范围,证明该算子在当前网络场景下梯度计算有误,可以对比CPU或GPU结果证明。该项优先级应低于[1.](#li17755175510322)与[2.](#li25281726103316),因为1与2的错误同样可以造成grad异常。
|
||||
@@ -1692,7 +1756,6 @@ def main():
|
||||
|
||||
- 解决方案:改进计算grad的算子精度或功能问题。
|
||||
|
||||
|
||||
4. 多卡计算错误。
|
||||
|
||||
- 定位思路:在保证单卡精度OK的前提下,稳定复现多卡不收敛。
|
||||
@@ -1703,6 +1766,55 @@ def main():
|
||||
|
||||
<h2 id="精度调优方法.md">精度调优方法</h2>
|
||||
|
||||
模型出现精度问题一般有:因算子溢出导致的训练loss不收敛或者精度不达标问题,整个网络训练引起的性能不达标问题。用户可通过单算子溢出检测和整网调测适度解决模型精度不达标问题。
|
||||
|
||||
- **[单算子溢出检测](#单算子溢出检测.md)**
|
||||
|
||||
- **[整网调测](#整网调测.md)**
|
||||
|
||||
|
||||
<h2 id="单算子溢出检测.md">单算子溢出检测</h2>
|
||||
|
||||
用户通过采集训练过程中各算子的运算结果(即Dump数据),然后查看算子是否产生溢出,从而帮助开发人员快速定位并解决算子精度问题。
|
||||
|
||||
## 约束说明<a name="section52762019181510"></a>
|
||||
|
||||
- 需要安装hdf5工具以支持算子dump功能,安装详情请参见[编译安装hdf5](#编译安装hdf5.md);
|
||||
- 本功能只提供IR级别的算子溢出检测,且只支持AICORE的溢出检测,不支持Atomic溢出检测;
|
||||
- 须在PyTorch源代码“build.sh“文件中添加“USE\_DUMP=1”字段。
|
||||
|
||||
```
|
||||
修改前: DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 python3 setup.py build bdist_wheel
|
||||
修改后: DEBUG=0 USE_DISTRIBUTED=1 USE_HCCL=1 USE_MKLDNN=0 USE_CUDA=0 USE_NPU=1 BUILD_TEST=0 USE_NNPACK=0 USE_DUMP=1 python3 setup.py build
|
||||
```
|
||||
|
||||
并参见《PyTorch安装指南》的“手动编译安装”章节重新编译并安装PyTorch。
|
||||
|
||||
- 使用单算子溢出检测功能时,请不要同时开启apex的动态loss scale模式和使用tensor融合功能。
|
||||
|
||||
## 采集算子Dump数据<a name="section121407268191"></a>
|
||||
|
||||
```
|
||||
# check_overflow为溢出检测控制开关
|
||||
# dump_path为dump文件保存路径
|
||||
with torch.utils.dumper(check_overflow=check_overflow, dump_path=dump_path, load_file_path='') as dump:
|
||||
# 需要算子采集的代码片段
|
||||
```
|
||||
|
||||
模型运行过程中,如果有算子溢出,会打印出相应IR的名字。
|
||||
|
||||
## 查看Dump数据<a name="section155351957142017"></a>
|
||||
|
||||
如果训练过程中采集到了Dump数据,则会在\{dump\_path\}路径下生成dump数据的.h5文件,用户可进入路径自行查看。
|
||||
|
||||
## 解决方法<a name="section1729763162019"></a>
|
||||
|
||||
请将算子溢出的打印截图及采集到的.h5文件通过Issue附件形式反馈给华为开发人员。
|
||||
|
||||
<h2 id="整网调测.md">整网调测</h2>
|
||||
|
||||
用户也可通过分析整个网络的方式来进行网络模型的精度调测。
|
||||
|
||||
1. 通过对比CPU和昇腾AI处理器的结果,判断在昇腾AI处理器上计算是否正确。
|
||||
|
||||
代码样例(本样例只体现基本方法,禁止直接复制)如下:
|
||||
@@ -1780,7 +1892,7 @@ def main():
|
||||
|
||||
离线推理应用构建请参考《CANN 应用软件开发指南\(C&C++, 推理\)》。整体流程如下:
|
||||
|
||||

|
||||

|
||||
|
||||
<h2 id="模型保存.md">模型保存</h2>
|
||||
|
||||
@@ -1813,7 +1925,6 @@ Pytorch在训练过程中,通常使用torch.save\(\)来保存Checkpoint文件
|
||||
model.eval()
|
||||
```
|
||||
|
||||
|
||||
> **须知:**
|
||||
>保存.pth或.pt文件扩展名的文件时要提供模型定义文件,否则无法部署。
|
||||
|
||||
@@ -2061,10 +2172,10 @@ if __name__ == "__main__":
|
||||
# if not torch.cuda.is_available():
|
||||
# print('using CPU, this will be slow')
|
||||
# elif args.distributed:
|
||||
############## npu modify begin #############
|
||||
############## npu modify begin #############
|
||||
# 迁移后为直接判断是否进行分布式训练,去掉判断是否在GPU上进行训练
|
||||
if args.distributed:
|
||||
############## npu modify end #############
|
||||
############## npu modify end #############
|
||||
# For multiprocessing distributed, DistributedDataParallel constructor
|
||||
# should always set the single device scope, otherwise,
|
||||
# DistributedDataParallel will use all available devices.
|
||||
@@ -2122,7 +2233,6 @@ if __name__ == "__main__":
|
||||
############## npu modify end #############
|
||||
```
|
||||
|
||||
|
||||
- 代码位置:main.py文件中的validate\(\)函数(修改部分为字体加粗部分):
|
||||
|
||||
```
|
||||
@@ -2142,7 +2252,6 @@ if __name__ == "__main__":
|
||||
############## npu modify end #############
|
||||
```
|
||||
|
||||
|
||||
6. 设置当前正在使用的device。
|
||||
|
||||
代码位置:main.py文件中的主函数入口(修改部分为字体加粗部分):
|
||||
@@ -2395,7 +2504,7 @@ if __name__ == "__main__":
|
||||
|
||||
if args.amp:
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level=args.opt_level, loss_scale=args.loss_scale)
|
||||
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], broadcast_buffers=False)
|
||||
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu])
|
||||
|
||||
# optionally resume from a checkpoint
|
||||
if args.resume:
|
||||
@@ -2525,7 +2634,7 @@ if __name__ == "__main__":
|
||||
单卡:
|
||||
|
||||
```
|
||||
python3.7 main.py /home/data/resnet50/imagenet --batch-size 128 \ # 训练批次大小
|
||||
python3 main.py /home/data/resnet50/imagenet --batch-size 128 \ # 训练批次大小
|
||||
--lr 0.1 \ # 学习率
|
||||
--epochs 90 \ # 训练迭代轮数
|
||||
--arch resnet50 \ # 模型架构
|
||||
@@ -2539,7 +2648,7 @@ python3.7 main.py /home/data/resnet50/imagenet --batch-size 128 \ # 训练
|
||||
分布式:
|
||||
|
||||
```
|
||||
python3.7 main.py /home/data/resnet50/imagenet --addr='1.1.1.1' \ # 示例IP地址,请根据实际修改
|
||||
python3 main.py /home/data/resnet50/imagenet --addr='1.1.1.1' \ # 示例IP地址,请根据实际修改
|
||||
--seed 49 \ # 随机种子
|
||||
--workers 160 \ # 加载数据进程数
|
||||
--lr 0.8 \
|
||||
@@ -3112,6 +3221,8 @@ for group in [2, 4, 8]:
|
||||
|
||||
- **[安装7.3.0版本gcc](#安装7-3-0版本gcc.md)**
|
||||
|
||||
- **[编译安装hdf5](#编译安装hdf5.md)**
|
||||
|
||||
|
||||
<h2 id="单算子样例编写说明.md">单算子样例编写说明</h2>
|
||||
|
||||
@@ -3303,7 +3414,7 @@ torch.npu.finalize_dump()
|
||||
|
||||
4. 调用Python,转换numpy文件为txt文件。举例:
|
||||
|
||||
**$ python3.7.5**
|
||||
**$ python3**
|
||||
|
||||
**\>\>\> import numpy as np**
|
||||
|
||||
@@ -3431,6 +3542,43 @@ torch.npu.finalize_dump()
|
||||
>本步骤为用户在需要用到gcc升级后的编译环境时才配置环境变量。
|
||||
|
||||
|
||||
<h2 id="编译安装hdf5.md">编译安装hdf5</h2>
|
||||
|
||||
以下步骤请在root用户下执行。
|
||||
|
||||
1. 获取代码。
|
||||
|
||||
```
|
||||
git clone https://github.com/HDFGroup/hdf5.git
|
||||
```
|
||||
|
||||
2. 切换到hdf5-1\_10\_7分支。
|
||||
|
||||
```
|
||||
cd hdf5
|
||||
git checkout remotes/origin/hdf5_1_10_7
|
||||
```
|
||||
|
||||
3. 编译hdf5。
|
||||
|
||||
```
|
||||
./configure --prefix=/usr/local/hdf5 --enable-cxx
|
||||
make -j72 #-j 后的数值可以根据CPU的核数设置
|
||||
make check # run test suite.
|
||||
make install
|
||||
make check-install # verify installation.
|
||||
```
|
||||
|
||||
4. 添加环境变量。
|
||||
|
||||
```
|
||||
export PATH=/usr/local/hdf5/bin:$PATH
|
||||
export LD_LIBRARY_PATH=/usr/local/hdf5/lib:$LD_LIBRARY_PATH
|
||||
export LIBRARY_PATH=/usr/local/hdf5/lib:$LIBRARY_PATH
|
||||
export CPATH=/usr/local/hdf5/include:$CPATH
|
||||
```
|
||||
|
||||
|
||||
<h2 id="FAQ.md">FAQ</h2>
|
||||
|
||||
- **[软件安装常见问题](#软件安装常见问题.md)**
|
||||
@@ -3488,7 +3636,7 @@ pip3.7 install pillow==5.3.0安装失败。
|
||||
|
||||
- **[在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed.md)**
|
||||
|
||||
- **[在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”1](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-1.md)**
|
||||
- **[在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”](#在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-7.md)**
|
||||
|
||||
- **[在模型运行时将多任务下发关闭\(export TASK\_QUEUE\_ENABLE=0\)后仍然遇到报错“HelpACLExecute.”](#在模型运行时将多任务下发关闭(export-TASK_QUEUE_ENABLE-0)后仍然遇到报错-HelpACLExecute.md)**
|
||||
|
||||
@@ -3677,7 +3825,7 @@ shell报错是在同步操作中和AI CPU错误,而日志报错信息却是在
|
||||
4. 打印stack所有参数的shape、dtype、npu\_format,通过构造单算子用例复现问题。定位到问题原因为减法计算输入参数数据类型不同,导致a-b和b-a结果的数据类型不一致,最终在stack算子中报错。
|
||||
5. 将stack入参数据类型转换为一致即可临时规避问题。
|
||||
|
||||
<h2 id="在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-1.md">在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”1</h2>
|
||||
<h2 id="在模型运行时遇到报错-MemCopySync-drvMemcpy-failed-7.md">在模型运行时遇到报错“MemCopySync:drvMemcpy failed.”</h2>
|
||||
|
||||
## 现象描述<a name="section1785905019184"></a>
|
||||
|
||||
@@ -3884,7 +4032,7 @@ pytorch算子在npu上运行,通过ACL接口调用底层经过优化的算子
|
||||
|
||||
## 现象描述<a name="section1785905019184"></a>
|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
|
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: 356 B After Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 28 KiB |
@@ -1,139 +0,0 @@
|
||||
# PyTorch版本说明书
|
||||
- [用户须知](#用户须知.md)
|
||||
- [新增特性](#新增特性.md)
|
||||
- [特性修改](#特性修改.md)
|
||||
- [已修复问题](#已修复问题.md)
|
||||
- [已知问题](#已知问题.md)
|
||||
- [兼容性](#兼容性.md)
|
||||
<h2 id="用户须知.md">用户须知</h2>
|
||||
|
||||
本框架基于Facebook主导的开源PyTorch1.5.0进行修改,延续原生的PyTorch特性,使用NPU进行动态图训练;以算子粒度进行模型适配,代码重用性好,支持现有的网络只修改设备类型或数据类型,即可迁移到NPU上使用。
|
||||
|
||||
<h2 id="新增特性.md">新增特性</h2>
|
||||
|
||||
**表 1** PyTorch支持的版本特性列表
|
||||
|
||||
<a name="t76c34275cbb74753970f7c5a9eb594fa"></a>
|
||||
<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>一级特性</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>二级特性</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>说明</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>适配训练模型</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>适配NPU的PyTorch特性</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>框架基础功能</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>新增适配算子开发(详见算子清单)。</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>精度对比工具</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19616115953816"><a name="p19616115953816"></a><a name="p19616115953816"></a>新增精度对比工具,支持训练精度定界。</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>昇腾710芯片</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p186161459193813"><a name="p186161459193813"></a><a name="p186161459193813"></a>新增支持昇腾710芯片在线推理。</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兼容性</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p8935115971714"><a name="p8935115971714"></a><a name="p8935115971714"></a>新增支持ubuntu 18.04.5、OpenEuler 20.03 LTS系统</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="特性修改.md">特性修改</h2>
|
||||
|
||||
不涉及
|
||||
|
||||
<h2 id="已修复问题.md">已修复问题</h2>
|
||||
|
||||
不涉及
|
||||
|
||||
<h2 id="已知问题.md">已知问题</h2>
|
||||
|
||||
<a name="table1969972073016"></a>
|
||||
<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>已知问题</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>问题描述</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>数据类型支持</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>NPU不支持float16类型的inf/nan数据输入输出。</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>数据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>出现4D以上的format时不能降维。</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>集合通信约束</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>要求一次训练任务中不同device上执行的图相同。</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>当前只支持1/2/4/8P粒度的分配。</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>只支持int8,int32,float16和float32数据类型。</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功能支持</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>Apex当前版本的实现方式主要为python实现,不支持APEX中的自定义优化CUDA Kernel。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="兼容性.md">兼容性</h2>
|
||||
|
||||
A800-9010:CentOS 7.6/Ubuntu 18.04/BC-Linux 7.6/Debian 9.9/Debian 10/OpenEuler 20.03 LTS
|
||||
|
||||
A800-9000:CentOS 7.6/Euler 2.8/Kylin v10/BC-Linux 7.6/OpenEuler 20.03 LTS
|
||||
|
||||
|
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 |
@@ -1,3 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, Huawei Technologies Co., Ltd
|
||||
# All rights reserved.
|
||||
#
|
||||
# Licensed under the BSD 3-Clause License (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
CUR_DIR=$(dirname $(readlink -f $0))
|
||||
ROOT_DIR=$CUR_DIR/..
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, Huawei Technologies Co., Ltd
|
||||
# All rights reserved.
|
||||
#
|
||||
# Licensed under the BSD 3-Clause License (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
diff -Nur --exclude=.git* --exclude=.jenkins --exclude=android --exclude=OWNERS --exclude=third_party --exclude=README* -Nur pytorch-v1.5.0 pytorch-develop >npu.patch
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, Huawei Technologies Co., Ltd
|
||||
# All rights reserved.
|
||||
#
|
||||
# Licensed under the BSD 3-Clause License (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
CUR_DIR=$(dirname $(readlink -f $0))
|
||||
ROOT_DIR=$CUR_DIR/..
|
||||
|
||||