Compare commits

...
481 Commits
Author SHA1 Message Date
i-robot 9be3044253 !3216 [Fix] Update torch1.8.1+cpu download url .
Merge pull request !3216 from 彭子荣/v1.8.1-3.0.0
2023-05-06 08:44:58 +00:00
pengzirong 4bc8cc1721 update torch1.8.1+cpu download url 2023-05-06 15:58:33 +08:00
i-robot e97f481814 !2750 [Fix] Fix bug when printing npu native format tensor.
Merge pull request !2750 from 刘嘉巍/v1.8.1-3.0.0
2023-03-28 01:42:40 +00:00
尤安升 bc5c096aeb update OWNERS.
Signed-off-by: 尤安升 <youansheng@huawei.com>
2023-03-27 01:22:44 +00:00
i-robot 5a3a92c9de !2729 Fix the bug of the SigmoidCrossEntropyWithLogitsV2 and SigmoidCrossEntropyWithLogitsGradV2.
Merge pull request !2729 from 郑亚金/v1.8.1-3.0.0_zyj_sigmod_0324
2023-03-25 13:15:34 +00:00
刘嘉巍 697ddb085f Fix bug when printing npu native format tensor. 2023-03-25 12:05:32 +08:00
郑亚金 a01c2da2e8 Fix the bug of the SigmoidCrossEntropyWithLogitsV2 and SigmoidCrossEntropyWithLogitsGradV2. 2023-03-24 19:19:31 +08:00
i-robot c58dd85831 !2705 Make reciprocal support Integer.
Merge pull request !2705 from 郑亚金/v1.8.1-3.0.0_zyj_reciprocal_0321
2023-03-23 13:04:29 +00:00
郑亚金 b7d7efebcd Make reciprocal support integer. 2023-03-23 16:28:10 +08:00
i-robot 9234555a23 !2630 [BugFix]Fix the dtype bug of min and support minimum.out.
Merge pull request !2630 from 郑亚金/v1.8.1-3.0.0_zyj_minimum_0316
2023-03-20 12:27:57 +00:00
郑亚金 02d505c147 Enable the minimum operator to support the scenario where two parameter data type are inconsistent and provide the out interface. 2023-03-20 14:08:17 +08:00
i-robot 9b3e4ba7af !2642 Modification of ge op to handle tensors from different devices.
Merge pull request !2642 from Leon/18130
2023-03-18 02:27:18 +00:00
liangyunfan 4f6f627d44 Modification of ge op to handle tensors from different devices. 2023-03-17 15:05:11 +08:00
i-robot 93cd968d3d !2580 [BugFix] Fix gru_backward when batch_size==1.
Merge pull request !2580 from 戢芳/gru1.8_3.0
2023-03-16 13:50:56 +00:00
i-robot 628753601e !2562 [Fix] Delete docs without releasenote .
Merge pull request !2562 from 彭子荣/v1.8.1-3.0.0
2023-03-16 02:36:54 +00:00
i-robot 3416fb40a5 !2594 the operator "onehot" supports empty tensor input
Merge pull request !2594 from 陈龙胜/onehot1.8-3.0.0
2023-03-15 11:15:24 +00:00
weili10 f153648550 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-03-15 07:16:02 +00:00
cls214 0a019b6727 Modify the adaptation code of the operator "onehot" to support empty tensor input
Type: feature
Team: Pytorch_Ops_Dev
Issue: NA
Description:
1.Remove redundancy check
2.When null tensors are input, normal results are returned without error
2023-03-15 11:16:35 +08:00
pipihugh 946a0e8ec1 Fix gru_backward when batch_size==1. 2023-03-14 15:11:04 +08:00
pengzirong b66932d2f3 delete docs (except releasenote) 2023-03-13 09:29:13 +08:00
weili10 7012d29c24 update torch package name.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-03-10 10:35:09 +00:00
i-robot 35277de150 !2528 [Fix] Update README quick install steps & link to hisascend-community.
Merge pull request !2528 from 彭子荣/v1.8.1-3.0.0
2023-03-10 09:20:21 +00:00
pengzirong fc45c7a540 update README quick install & add link to Hiascend 2023-03-10 15:59:15 +08:00
i-robot 660da0e85d !2482 [BugFix]Full operation fill with dtype inferred from fill_value.
Merge pull request !2482 from 邵非凡/full-1.8-3.0.0
2023-03-02 03:32:47 +00:00
邵非凡 f420148b77 Full operation fill with dtype inferred from fill_value. 2023-03-01 16:16:39 +08:00
i-robot e50c34dfea !2440 [bugfix] Add dtype cast when input dtype is int64, because the OneHot cann't support it.
Merge pull request !2440 from 郭夏/onehot_1.8.1-3.0
2023-02-28 07:19:42 +00:00
i-robot aad0b4de4e !2388 【bugfix】Support the param out is a slice of other tensor, in max.
Merge pull request !2388 from 郭夏/max_out
2023-02-27 06:40:26 +00:00
郭夏 8e33c02f0f [bugfix] Add dtype cast when input dtype is int64, because the OneHot cann't support it.
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2023-02-27 11:37:13 +08:00
i-robot 92322edbc4 !2398 [BugFix] Fix embedding_bag in 0D scenario.
Merge pull request !2398 from 戢芳/embedding1.8_3.0
2023-02-27 01:24:40 +00:00
i-robot d8bc3ab390 !2363 [Fix] Update version 3.0.0 ReleaseNote .
Merge pull request !2363 from 彭子荣/v1.8.1-3.0.0
2023-02-23 12:36:57 +00:00
i-robot 4303b8e77f !2418 [bugfix] Fix uniform kernel error.
Merge pull request !2418 from will-devil/bf183dev
2023-02-23 12:30:31 +00:00
wangyicheng c01fcce508 Fix uniform kernel error. 2023-02-23 17:19:29 +08:00
i-robot 3694f59418 !2386 [bugfix] Fix uniform kernel forward error.
Merge pull request !2386 from will-devil/183dev
2023-02-22 07:36:16 +00:00
郭夏 2fa5dc6b0b 【bugfix】Support the param out is a slice of other tensor, in max.
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2023-02-22 13:26:56 +08:00
pipihugh 883d7e923e Fix embedding_bag in 0D scenario. 2023-02-22 11:12:56 +08:00
wangyicheng 20750f0a9a Fix uniform kernel forward error. 2023-02-21 10:08:24 +08:00
i-robot 2eaf9d2944 !2294 Fix input device for get_rng_state and set_rng_state.
Merge pull request !2294 from shaoyf/fix/181_300_rng_state
2023-02-17 09:06:54 +00:00
pengzirong 7c67039927 更新3.0.0版本RELEASENOTE 2023-02-17 17:00:50 +08:00
i-robot 0488caf153 !2314 [Fix] Fix the deadlock in taskqueue
Merge pull request !2314 from 詹昊/v1.8.1-3.0.0
2023-02-16 08:51:52 +00:00
zhanhao 89c6412295 Fix the deadlock in taskqueue 2023-02-15 15:38:34 +08:00
i-robot c5ac2f45a9 !2303 [Fix]Fix the input tensor src_stride under aicore mode.
Merge pull request !2303 from 於欣洁/v1.8.1-3.0.0_vc0213
2023-02-14 02:04:28 +00:00
weili10 4ea5135d4d update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-02-13 13:25:54 +00:00
yuxinjie 50d3504b51 Fix the input tensor src_stride under aicore mode. 2023-02-13 20:23:06 +08:00
i-robot 046244ed74 !2284 [Fix] Fix no attribute python_exit_status.
Merge pull request !2284 from 龚俊强/v1.8.1-3.0.0
2023-02-13 08:25:05 +00:00
shaoyf 1cb32e90a7 Fix input device for get_rng_state and set_rng_state. 2023-02-13 15:39:11 +08:00
junqiang521 dc1ef0eb00 Master version upgrade, update _shutdown_workers 2023-02-13 14:55:21 +08:00
i-robot caf9a961a6 !2269 Fix output shape of lstm_backward.
Merge pull request !2269 from 郑亚金/v1.8.1-3.0.0_zyj_lstm_0209
2023-02-11 09:10:55 +00:00
郑亚金 746688c5be Fix output shape of lstm_backward. 2023-02-11 16:00:36 +08:00
i-robot e03782361b !2279 [Fix] fix isinstance bug in transfer_to_npu tools
Merge pull request !2279 from 施博/instance_v18_3
2023-02-10 11:30:50 +00:00
i-robot ef1793c9e2 !2275 [Fix] fix device constructor bug
Merge pull request !2275 from 施博/fix_device_assert_v18_3
2023-02-10 09:52:09 +00:00
shibo19 e8697157a2 fix isinstance bug in transfer_to_npu tools 2023-02-10 17:27:45 +08:00
i-robot b2e048fc97 !2205 [Feature] Add NpuPreGenDropout feature
Merge pull request !2205 from 宁振江/v1.8.1-3.0.0
2023-02-10 08:59:02 +00:00
shibo19 f65d54dcfa fix device constructor bug 2023-02-10 16:47:34 +08:00
ningzhenjiang 2df89a8d08 Add NpuPreGenDropout feature 2023-02-10 14:58:35 +08:00
i-robot 34ac9dfd52 !2254 Add Attr of Swish.
Merge pull request !2254 from 戢芳/swish1.8
2023-02-10 03:23:42 +00:00
i-robot 5e8296002d !2257 Fix clamp in int64 scenario.
Merge pull request !2257 from 戢芳/clamp1.8
2023-02-10 03:21:20 +00:00
i-robot e5da392470 !2264 Correct the output dtype of pow.
Merge pull request !2264 from 郑亚金/v1.8.1-3.0.0_zyj_pow_0209
2023-02-10 02:55:48 +00:00
i-robot a3ecdfba7a !2250 [Fix] parameter parsing error when 'device=None'.
Merge pull request !2250 from 杜金航/v1.8.1-3.0.0
2023-02-09 12:37:51 +00:00
郑亚金 058c855e48 Correct the output dtype of pow. 2023-02-09 16:04:06 +08:00
pipihugh 0edce2564c Fix clamp in int64 scenario. 2023-02-09 10:50:40 +08:00
pipihugh efa59b2200 Add Attr of Swish. 2023-02-09 09:41:38 +08:00
dujinhang c95745e790 [Fix] parameter parsing error when 'device=None'. 2023-02-08 17:32:42 +08:00
i-robot bdf3d95bd6 !2208 Torch.load supports npu tensor load to cpu.
Merge pull request !2208 from 闫鹏全/v1.8.1-3.0.0
2023-02-07 15:39:33 +00:00
闫鹏全 735eace090 Merge branch.
Signed-off-by: 闫鹏全 <yanpengquan@huawei.com>
2023-02-07 14:27:59 +00:00
i-robot 5a26719308 !2246 [Fix] Fix device class bug
Merge pull request !2246 from 施博/fix_device_assert_v18_3
2023-02-07 13:53:25 +00:00
shibo19 3633a172e7 fix device class bug 2023-02-07 20:28:19 +08:00
i-robot 9df30bd765 !2239 Strengthen index operator verification.
Merge pull request !2239 from 刘哲续/v1.8.1-3.0.0
2023-02-07 12:04:50 +00:00
刘哲续 8ff2d0947d Strengthen index operator verification. 2023-02-07 17:25:46 +08:00
闫鹏全 524f6a9663 Torch.load supports npu tensor load to cpu. 2023-02-07 17:11:34 +08:00
i-robot 5bf3c1722a !2206 [Fix] Fix bug in storage_resize_npu.
Merge pull request !2206 from 刘嘉巍/v1.8.1-3.0.0
2023-02-07 08:43:16 +00:00
i-robot d9a7fc180a !2233 [Fix] Fix instance assert bug for torch_npu._C.device
Merge pull request !2233 from 施博/fix_device_assert_v18_3
2023-02-07 06:43:44 +00:00
shibo19 24d1c22e18 fix assert for torch_npu._C.device 2023-02-07 11:06:24 +08:00
i-robot f06123b41a !2229 FusedColorjitter moving the position of the import pillow avoids the problem of dependencies when importing torch_npu
Merge pull request !2229 from 王姜奔/v1.8.1-3.0.0
2023-02-06 13:37:16 +00:00
王姜奔 0562c43fcc Moving the position of the import pillow avoids the problem of dependencies when importing torch_npu
Signed-off-by: 王姜奔 <wangjiangben@huawei.com>
2023-02-06 11:45:46 +00:00
i-robot 0ddf5e6ebc !2223 [Fix] Fix device type bug in serialization
Merge pull request !2223 from 施博/fix_device_v3.0
2023-02-06 06:24:23 +00:00
shibo19 41a0d2e918 fix device type bug in serialization 2023-02-06 10:19:11 +08:00
i-robot 10086fd264 !2190 Restore the adaptation of fill_.
Merge pull request !2190 from 戢芳/fill1.8_3.0
2023-02-06 01:08:22 +00:00
i-robot a3c056fa5d !2196 [Fix] Taskqueue add memory barrier.
Merge pull request !2196 from 詹昊/v1.8.1-3.0.0
2023-02-04 03:45:16 +00:00
i-robot 3178fd9561 !2173 [Fix] Add class "Device" for torch_npu
Merge pull request !2173 from 施博/fix_device_18
2023-02-03 08:02:11 +00:00
施博 3142dcecea Merge branch 'v1.8.1-3.0.0' of gitee.com:ascend/pytorch into fix_device_18
Signed-off-by: 施博 <shibo19@huawei.com>
2023-02-02 09:22:57 +00:00
shibo19 fa2157ce49 Add class "Device" for torch_npu 2023-02-02 17:22:16 +08:00
pipihugh 2a0c8f1196 Restore the adaptation of fill_. 2023-02-02 16:32:38 +08:00
zhanhao 05050c7e6b Taskqueue add memory barrier 2023-02-02 16:18:46 +08:00
刘嘉巍 e7bf9e6a1c Fix bug in storage_resize_npu 2023-02-02 16:15:08 +08:00
weili10 1b95bdcdd3 update cann version.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-30 13:21:18 +00:00
weili10 b084d6df58 update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-19 08:15:15 +00:00
weili10 db8edc442d update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-19 07:57:08 +00:00
weili10 109ca03752 update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-19 07:56:01 +00:00
i-robot 6ce98a9a92 !2130 Modify the default value of the TASK_QUEUE_ENABLE.
Merge pull request !2130 from shaoyf/181_300/task_queue
2023-01-14 11:37:10 +00:00
shaoyf 31709876be Modify the default value of the TASK_QUEUE_ENABLE. 2023-01-14 19:00:50 +08:00
weili10 c62ab664a5 !2121 [Fix] Modify syncbn to the original implementation.
Merge pull request !2121 from shaoyf/bugfix/syncbn
2023-01-13 10:03:13 +00:00
shaoyf 533e520179 Modify syncbn to the original implementation. 2023-01-13 17:01:00 +08:00
i-robot 586cf41a3f !2116 [Fix] Fixed npu device not torch.device type issue.
Merge pull request !2116 from 杜金航/v1.8.1-3.0.0
2023-01-12 14:24:12 +00:00
dujinhang 0ee3963ed6 [Fix] Fixed npu device not torch.device type issue. 2023-01-12 22:07:52 +08:00
i-robot c06919b836 !2109 [perf] topk optimize
Merge pull request !2109 from yangxiaorun/cherry-pick-1673493339
2023-01-12 11:39:13 +00:00
yangxiaorun 8615ed3b4f fixed e2603be from https://gitee.com/yangxiaorun1/pytorch/pulls/2107
perf: topk perf optimize
2023-01-12 03:15:39 +00:00
i-robot 37080cf443 !2104 Modify mv to adapt MatMul's ND case.
Merge pull request !2104 from 王晓/mv_nd_1.8_3.0.0
2023-01-11 15:51:59 +00:00
wangxiao c78232d2c0 Modify mv and npu_linear to adapt MatMul's nd case. 2023-01-11 22:28:17 +08:00
i-robot d16be41674 !1972 [Refactor]Simplify the usage of accuracy comparison tool.
Merge pull request !1972 from 杜金航/v1.8.1-3.0.0
2023-01-11 03:27:18 +00:00
i-robot 630723267c !2082 [Fix] Update op list for AOE dump.
Merge pull request !2082 from 施博/aoe_v1.8
2023-01-10 08:34:15 +00:00
i-robot 795b968518 !2096 Migrate checkpoint feature to 1.8.1-3.0.0 branch
Merge pull request !2096 from hanjun/v1.8.1-3.0.0
2023-01-10 03:10:16 +00:00
h00558267 2757d5e475 Migrate checkpoint feature to 1.8.1-3.0.0 branch 2023-01-10 10:37:13 +08:00
i-robot 318739a04d !2072 [Feature] Add backward function of npu_convolution_backward.
Merge pull request !2072 from 郭夏/v1.8.1-3.0.0
2023-01-09 12:55:30 +00:00
i-robot 3131cd3e3d !2087 [Fix]Fix silu inplace backward.
Merge pull request !2087 from 王晓/silu_1.8_3.0.0
2023-01-09 12:18:38 +00:00
i-robot c5e9f8a65d !2083 [Fix] Add attr of GatherV2.
Merge pull request !2083 from 戢芳/gather3.0
2023-01-09 12:17:58 +00:00
wangxiao bf96de52ce Fix silu inplace backward. 2023-01-09 19:16:58 +08:00
郭夏 3d00ccb838 [Feature] Add backward function of npu_convolution_backward.
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2023-01-09 18:48:21 +08:00
shibo19 0958ececf5 Update op list for AOE dump 2023-01-09 17:19:31 +08:00
pipihugh dca1a1e942 Add attr of GatherV2. 2023-01-09 13:39:15 +08:00
i-robot 6c2dc57411 !2064 [BugFix] Adjust the index adaptation logic.
Merge pull request !2064 from 刘哲续/v1.8.1-3.0.0
2023-01-08 08:33:43 +00:00
刘哲续 5bd3a895e9 Adjust the index adaptation logic. 2023-01-07 22:11:31 +08:00
i-robot e7328150c8 !2079 [Fix] Output int32 When the input of sum is int or bool.
Merge pull request !2079 from 戢芳/sum3.0
2023-01-07 12:57:11 +00:00
pipihugh 32a5b98293 Output int32 When the input of sum is int or bool. 2023-01-07 14:40:58 +08:00
i-robot bceda430c8 !2065 [Fix] Fix the problem of cnt can not be 0.
Merge pull request !2065 from 詹昊/v1.8.1-3.0.0
2023-01-06 09:57:36 +00:00
zhanhao 9edb9058f0 Fix the problem of cnt can not be 0. 2023-01-06 17:10:06 +08:00
i-robot 4e7e9da29c !2052 [Feature] Add adapters of tril_indices and triu_indices.
Merge pull request !2052 from 戢芳/triu_indices3.0
2023-01-06 03:45:30 +00:00
dujinhang d7d201d251 [Synchronize]Simplify the usage of accuracy comparison tool. 2023-01-06 11:44:48 +08:00
i-robot 95e9590880 !2058 IndexPut support 1D broadcast case
Merge pull request !2058 from 王晓歆/indexput_new_shang
2023-01-05 13:47:43 +00:00
i-robot 68897be92e !2053 Reduce Transpose calls of npu_deformable_conv2d.
Merge pull request !2053 from 王晓/nhwc_fix_v2_3.0.0
2023-01-05 13:37:59 +00:00
i-robot 6c9cce4cb8 !2044 [Fix] Adjust the Index adaptation logic.
Merge pull request !2044 from 刘哲续/v1.8.1-3.0.0
2023-01-05 13:35:19 +00:00
i-robot 6adf15d1dd !2048 [bugfix] Modify InferShapeofNHWC.
Merge pull request !2048 from will-devil/shapedev2
2023-01-05 13:31:49 +00:00
wangxiaoxin_sherie 1424ab9c91 indexput support 1D broadcast case 2023-01-05 21:03:51 +08:00
刘哲续 0a25bdb394 Adjust the Index adaptation logic. 2023-01-05 20:08:32 +08:00
wangyicheng a60114d389 Modify InferShapeofNHWC. 2023-01-05 19:52:38 +08:00
i-robot 8fbcaa2542 !2055 [Cleancode] Clean code for all.
Merge pull request !2055 from shaoyf/cleancode/181_300
2023-01-05 11:44:27 +00:00
i-robot 2c4dd2a28e !2040 Fix hardsigmoid_ and add corresponding cases.
Merge pull request !2040 from 戢芳/hardsigmoid3.0
2023-01-05 11:22:13 +00:00
pipihugh 9ff2ac83a7 Add adapters of tril_indices and triu_indices. 2023-01-05 13:55:14 +08:00
shaoyf a8ed592d30 Clean code for all. 2023-01-05 13:46:45 +08:00
wangxiao f3953ad39f Reduce Transpose calls of npu_deformable_conv2d. 2023-01-05 10:36:03 +08:00
i-robot 558385f933 !2023 [Fix]Add flag in read and write queue.
Merge pull request !2023 from 詹昊/v1.8.1-3.0.0
2023-01-05 02:25:38 +00:00
i-robot 5931ccc0e0 !2043 [Fix] Fix new_zeros and new_empty without args.
Merge pull request !2043 from shaoyf/cherry-pick-1672831738
2023-01-04 12:29:25 +00:00
zhanhao 510d4e38bf Add flag in read and write queue. 2023-01-04 20:18:03 +08:00
shaoyf abe3638940 fixed ac8cade from https://gitee.com/shaoyf/pytorch/pulls/2035
Fix new_zeros and new_empty without args.
2023-01-04 11:28:59 +00:00
i-robot 4276d15246 !2038 [Fix]IndexPut unsupport bool incomplete axis
Merge pull request !2038 from 王晓歆/indexput_new_shang
2023-01-04 11:28:27 +00:00
pipihugh 68e6904aad Fix hardsigmoid_ and add corresponding cases. 2023-01-04 16:21:17 +08:00
wangxiaoxin_sherie c1b685ec15 Intercept bool non full axis case. 2023-01-04 15:55:34 +08:00
i-robot ae3acfa89c !2003 [bugfix] Set gate order of LSTM to ifjo, same as CPU's.
Merge pull request !2003 from 郭夏/lstm
2023-01-03 08:38:20 +00:00
weili10 905556dc1f !2012 Use ND as default format in MatMul
Merge pull request !2012 from weili10/revert-merge-1909-v1.8.1-3.0.0
2022-12-30 11:14:29 +00:00
weili10 b97f3d4125 回退 'Pull Request !1909 : [fix] revert cast ND in Matmul' 2022-12-30 10:17:13 +00:00
i-robot dd1a210f0b !1981 [Fix] Syncbn support input shape (N,C,+)
Merge pull request !1981 from huangxinliang/v1.8.1-3.0.0
2022-12-30 06:15:53 +00:00
xinlianglalala 1f17bd7b31 Do reshape to support ND format 2022-12-30 12:10:00 +08:00
郭夏 c837ed95f9 [bugfix]Set gate order of LSTM to ifjo, same as CPU's.
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2022-12-30 03:24:05 +00:00
i-robot c4718c766a !1975 Call Transpose explicitly in adapter of deformable_conv2d.
Merge pull request !1975 from 王晓/deformable_conv_nhwc2_3.0.0
2022-12-29 13:23:37 +00:00
i-robot 2d9d2c3954 !1997 Fix layer_norm shape error.
Merge pull request !1997 from 王晓/ln_resize_3.0.0
2022-12-29 09:06:27 +00:00
wangxiao bde8b65340 Fix layer_norm shape error. 2022-12-29 13:35:28 +08:00
i-robot 4bc8ff49b0 !1991 Fix compilation errors when the version.py file exists.
Merge pull request !1991 from 闫鹏全/v1.8.1-3.0.0
2022-12-27 13:51:04 +00:00
i-robot 4971b7b495 !1984 Index/IndexPut aicore operator adaptation.
Merge pull request !1984 from 王晓歆/indexput_shang
2022-12-27 13:04:32 +00:00
i-robot 4ef294bcc1 !1980 [BugFix] Correct the output shape of lstm_backward.
Merge pull request !1980 from 戢芳/lstm3.0
2022-12-27 10:19:03 +00:00
闫鹏全 4c32e388f8 Fix compilation errors when the version.py file exists. 2022-12-27 14:31:53 +08:00
i-robot 6a17bae281 !1977 [Fix] Only warning once when running unsupported kernel.
Merge pull request !1977 from 刘嘉巍/v1.8.1-3.0.0
2022-12-26 12:47:15 +00:00
wangxiaoxin_sherie 14996a93fc Add Index/IndexPut aicore adpater. 2022-12-26 19:19:19 +08:00
liu-jiaweikf 9fc040820b Warning only once 2022-12-26 18:02:49 +08:00
i-robot c78f539229 !1974 [BugFix] Fix the error of median and fill_.
Merge pull request !1974 from 戢芳/median3.0
2022-12-26 06:46:28 +00:00
pipihugh efd072dbb8 Correct the output shape of lstm_backward. 2022-12-26 13:55:09 +08:00
wangxiao f0a7a317d7 Call Transpose explicitly in adapter of deformable_conv2d. 2022-12-24 17:37:45 +08:00
weili10 deaf49c0f0 update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-23 11:55:52 +00:00
pipihugh 4dd75516a2 Fix the error of median and fill_. 2022-12-23 09:43:55 +08:00
i-robot c53382e05a !1971 [feature] memcpy async enqueue
Merge pull request !1971 from 王强/v1.8.1-3.0.0
2022-12-23 00:56:42 +00:00
i-robot 33fe989f66 !1958 Update the version number of the branch.
Merge pull request !1958 from 闫鹏全/v1.8.1-3.0.0
2022-12-22 13:12:25 +00:00
i-robot 7d42332443 !1969 [BugFix] Support npu:x format for Tensor.npu
Merge pull request !1969 from shaoyf/bugfix/npu_1.8.1-3.0.0
2022-12-22 13:11:27 +00:00
i-robot 32de06a915 !1900 Modify the framework of Viewcopy.
Merge pull request !1900 from 於欣洁/v1.8.1-3.0.0
2022-12-22 10:40:48 +00:00
x00430237 246a84e3fc [feature] memcpy async enqueue 2022-12-22 18:21:42 +08:00
shaoyf 58f18b5294 [BugFix] Support None for Tensor.npu. 2022-12-22 09:16:32 +00:00
闫鹏全 6d181d7004 Update the version number of the branch. 2022-12-22 16:33:37 +08:00
weili10 fa7a9e758d update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-21 12:48:17 +00:00
i-robot b02893d253 !1951 [Fix] Modify the default device of as_tensor.
Merge pull request !1951 from shaoyf/cherry-pick-1671537648
2022-12-21 04:05:03 +00:00
shaoyf 8a18825d2b fixed 0b5ebb4 from https://gitee.com/shaoyf/pytorch/pulls/1950
[Fix] Modify the default device of as_tensor.
2022-12-20 12:00:48 +00:00
i-robot a388e6de95 !1944 [BugFix] Fix the accuracy problem of nllloss2d.
Merge pull request !1944 from 戢芳/nllloss3.0
2022-12-20 03:51:04 +00:00
pipihugh 3fb8100078 Fix the accuracy problem of nllloss2d. 2022-12-20 09:18:15 +08:00
i-robot 1917d214e1 !1943 [Fix]: Modify error msg in HCCL op.
Merge pull request !1943 from 施博/hccl_error_v1.8
2022-12-19 12:32:16 +00:00
shibo19 28d2812ebf Fix: modify error msg in HCCL op 2022-12-19 20:27:43 +08:00
i-robot 2eefe1f1b0 !1938 Synchronize accuracy comparison and overflow detection tools to v1.8.1-3.0.0
Merge pull request !1938 from 杜金航/v1.8.1-3.0.0
2022-12-19 12:07:56 +00:00
i-robot ab8b1916bf !1941 [Fix] Fix bug in indexing contiguous operation.
Merge pull request !1941 from 刘嘉巍/v1.8.1-3.0.0
2022-12-19 11:32:19 +00:00
刘嘉巍 9e27f353fa Fix bug in indexing_opt 2022-12-19 16:30:35 +08:00
dujinhang e763367d81 Synchronize master to v1.8.1-3.0.0 2022-12-19 16:11:37 +08:00
i-robot 1986ba362e !1932 [Fix] revert 'Pull Request !1930 : Add Index/IndexPut Adaptation'
Merge pull request !1932 from weili10/revert-merge-1930-v1.8.1-3.0.0
2022-12-18 13:26:18 +00:00
weili10 92c00609f1 Modify the default value of the TASK_QUEUE_ENABLE
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-18 13:15:26 +00:00
weili10 61daeb2ec0 回退 'Pull Request !1930 : Add Index/IndexPut Adaptation' 2022-12-18 13:04:25 +00:00
i-robot a25a3f18ff !1930 Add Index/IndexPut Adaptation
Merge pull request !1930 from 赖长铃/index_indexput_c84
2022-12-17 15:41:58 +00:00
cling e5d06ab18a add index/indexput aicore kernel 2022-12-17 21:29:56 +08:00
i-robot 5e10771032 !1928 Add exclude aicore engine of viewcopy.
Merge pull request !1928 from 於欣洁/v1.8.1-3.0.0
2022-12-17 13:29:46 +00:00
i-robot e42a5e79f0 !1926 [BugFix] Correct the output shape of layer_norm_eval.
Merge pull request !1926 from 戢芳/layer_norm3.0
2022-12-17 11:23:58 +00:00
yuxinjie f3f9aec20f Add exclude aicore engine of viewcopy. 2022-12-17 19:11:43 +08:00
pipihugh 61972e558a Correct the output shape of layer_norm_eval. 2022-12-17 18:11:07 +08:00
i-robot 58bb15db8d !1923 [Feature] BatchNorm2d eliminate transdata in binary 5HD scenarios.
Merge pull request !1923 from 戢芳/bn_trans3.0
2022-12-17 08:35:40 +00:00
pipihugh b4163275eb BatchNorm2d eliminate transdata in binary 5HD scenarios. 2022-12-17 15:35:48 +08:00
yuxinjie b44bcea8db Modify the framework of viewcopy. 2022-12-17 11:57:55 +08:00
i-robot 2aee971f9d !1905 Synchronize master branch: private format rectification
Merge pull request !1905 from 戢芳/format3.0
2022-12-16 11:55:56 +00:00
i-robot e502a7c848 !1919 [Fix] Support torch.npu.FloatTensor for PyTorch installed by wheel(x86_64).
Merge pull request !1919 from shaoyf/cherry-pick-1671174122
2022-12-16 08:26:06 +00:00
i-robot 754cc15934 !1908 [Fix] Modify the error information of libhccl.so.
Merge pull request !1908 from 詹昊/v1.8.1-3.0.0
2022-12-16 07:33:49 +00:00
i-robot d29db7cc67 !1902 change asynchronous copy + stream synchronization to stream synchronization + synchronous copy
Merge pull request !1902 from 刘晶晶/aclrtMemcpy-3.0.0
2022-12-16 07:31:50 +00:00
weili10 7d04486423 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-16 07:27:17 +00:00
i-robot 6dbdc16833 !1915 Revert Index/IndexInput API
Merge pull request !1915 from 刘哲续/v1.8.1-3.0.0
2022-12-16 07:21:46 +00:00
shaoyf 89179e9144 fixed ca5852a from https://gitee.com/shaoyf/pytorch/pulls/1913
Support npu tensor for PyTorch installed by wheel(x86_64)
2022-12-16 07:02:03 +00:00
i-robot a77cbf6e97 !1916 [Fix] revert 'Pull Request !1889 : [Feature] Modify the size of AvgPoolV2Grad to int32'
Merge pull request !1916 from weili10/revert-merge-1889-v1.8.1-3.0.0
2022-12-16 06:53:46 +00:00
weili10 3861938495 回退 'Pull Request !1889 : [Feature] Modify the size of AvgPoolV2Grad to int32' 2022-12-16 06:31:31 +00:00
刘哲续 57321fab56 Revert Index/IndexPut API. 2022-12-16 12:06:00 +08:00
zhanhao 01e7fae8a3 Modify error infomation of libhccl.so 2022-12-16 11:57:03 +08:00
weili10 a0e28b3c66 !1909 [fix] revert cast ND in Matmul
Merge pull request !1909 from weili10/revert-merge-1787-v1.8.1-3.0.0
2022-12-15 16:39:12 +00:00
weili10 15b328eb42 回退 'Pull Request !1787 : ND default on for MatMul' 2022-12-15 16:23:37 +00:00
i-robot eb4004a53d !1904 [Fix]IndexPut reduce constraint
Merge pull request !1904 from 王晓歆/indexput_empty_shang
2022-12-15 15:20:53 +00:00
pipihugh e674440b47 Synchronize master branch: private format rectification. 2022-12-15 21:52:29 +08:00
wangxiaoxin_sherie ceea4fe18f Indexput reduce constraint 2022-12-15 21:50:12 +08:00
i-robot 32df77e9b7 !1892 [SF] Optimize the RepeatInterleave operator adaptation scheme
Merge pull request !1892 from aikede/sf_reInleave
2022-12-15 09:36:55 +00:00
liujingjing 3a82f9463f change asynchronous copy + stream synchronization to stream synchronization + synchronous copy 2022-12-15 15:38:51 +08:00
i-robot 1413e8ae6d !1899 Sync wrap_dtype_for_hccl to the v1.8.1-3.0.0 branch
Merge pull request !1899 from 王姜奔/v1.8.1-3.0.0
2022-12-15 07:02:39 +00:00
王姜奔 8c7f762370 add wrap_dtype_for_hccl 2022-12-15 14:36:11 +08:00
i-robot 2f63c547c4 !1884 [Fix] Optimize release queue.
Merge pull request !1884 from 詹昊/v1.8.1-3.0.0
2022-12-15 02:09:36 +00:00
weili10 46accd209d !1885 Add Index/IndexPut Adaptation.
Merge pull request !1885 from 刘哲续/v1.8.1-3.0.0
2022-12-14 15:47:14 +00:00
刘哲续 749276da5d Add Index/IndexPut Adaptation. 2022-12-14 22:41:28 +08:00
zhanhao ccd7267cee Optimize taskqueue. 2022-12-14 21:40:14 +08:00
i-robot 7dc5159e6d !1894 [Fix] revert 'Pull Request !1842 : [Feature] BatchNorm2d eliminate transdata in binary 5HD scenarios'
Merge pull request !1894 from weili10/revert-merge-1842-v1.8.1-3.0.0
2022-12-14 13:14:15 +00:00
aikede 89c499e336 Optimize the RepeatInterleave operator adaptation scheme 2022-12-14 20:56:48 +08:00
i-robot 2bcdf464d4 !1889 [Feature] Modify the size of AvgPoolV2Grad to int32
Merge pull request !1889 from 戢芳/avg_pool2d_grad3.0
2022-12-14 10:30:30 +00:00
weili10 744c908831 回退 'Pull Request !1842 : [Feature] BatchNorm2d eliminate transdata in binary 5HD scenarios' 2022-12-14 10:01:03 +00:00
pipihugh 6d681e0002 Modify the size of AvgPoolV2Grad to int32. 2022-12-14 15:51:33 +08:00
i-robot 5c11c8b594 !1882 [fix] revert deformable_conv2d changes
Merge pull request !1882 from weili10/revert-merge-1841-v1.8.1-3.0.0
2022-12-13 15:10:26 +00:00
weili10 184e7af7f9 回退 'Pull Request !1841 : Call Transpose explicitly in adapter of deformable_conv2d.' 2022-12-13 14:46:48 +00:00
i-robot 6baa844d09 !1879 Modified the Usage Guide of the accuracy comparison tool at GPU Scenarios
Merge pull request !1879 from 谭親林/v1.8.1-3.0.0
2022-12-13 14:32:11 +00:00
tanqinlin 63e4905e0d modify usage guide for GPU Scenarios 2022-12-13 22:14:11 +08:00
i-robot 59ada59f12 !1863 [Fix] Optimize log printing in taskqueue.
Merge pull request !1863 from 詹昊/v1.8.1-3.0.0
2022-12-13 14:02:14 +00:00
zhanhao ad159d4008 Add log printing to taskqueue. 2022-12-13 21:17:47 +08:00
i-robot a1ee328dba !1818 Device verification of tensor
Merge pull request !1818 from 王夏夏/v1.8.1-3.0.0
2022-12-13 13:16:29 +00:00
i-robot 45d935d980 !1851 Update Syncbn adapter for mixed precision training (v1.8.1-3.0.0)
Merge pull request !1851 from huangxinliang/v1.8.1-3.0.0
2022-12-13 12:50:31 +00:00
xinlianglalala 4d19446a9c Update Syncbn adapter for mixed precision training 2022-12-13 20:11:03 +08:00
i-robot 41340a0504 !1853 [Fix] Fix the precision error in allgather operator
Merge pull request !1853 from 施博/allgather_v18_3.0
2022-12-13 11:40:13 +00:00
i-robot 56fb98d377 !1854 Revert Index/IndexPut Adaptive logic
Merge pull request !1854 from 刘哲续/v1.8.1-3.0.0
2022-12-13 06:15:52 +00:00
刘哲续 3bf1ddde1b Revert Index/IndexPut adaptive logic. 2022-12-13 11:06:05 +08:00
shibo19 4ef89b5009 Bugfix: Fix the precision error in allgather operator 2022-12-13 10:11:05 +08:00
i-robot 46065dfb91 !1843 [Feature] Basic rectification of batchnorm eliminating transdata
Merge pull request !1843 from 戢芳/weight_3.0
2022-12-12 17:35:49 +00:00
i-robot 9eef5f5a13 !1842 [Feature] BatchNorm2d eliminate transdata in binary 5HD scenarios
Merge pull request !1842 from 戢芳/bn_transdata3.0
2022-12-12 17:33:51 +00:00
i-robot 24d72ba3b5 !1845 回退 'Pull Request !1796 : taskqueue优化'
Merge pull request !1845 from weili10/revert-merge-1796-v1.8.1-3.0.0
2022-12-12 15:55:50 +00:00
pipihugh 6b840a21cd BatchNorm2d eliminate transdata in binary 5HD scenarios. 2022-12-12 23:49:09 +08:00
weili10 805ed0b767 回退 'Pull Request !1796 : taskqueue优化' 2022-12-12 15:43:49 +00:00
i-robot 276a6fd592 !1816 【Feature】 Add the aicore branch of indexput
Merge pull request !1816 from 王晓歆/v1.8.1-3.0.0
2022-12-12 15:26:09 +00:00
i-robot 6dc23bbcb5 !1807 [Feature]Add the aicore branch of index
Merge pull request !1807 from 戢芳/index_aicore3.0
2022-12-12 15:21:50 +00:00
i-robot 0154df7c4c !1841 Call Transpose explicitly in adapter of deformable_conv2d.
Merge pull request !1841 from 王晓/deformable_conv_nhwc_3.0.0
2022-12-12 15:17:49 +00:00
pipihugh 4e4a123868 Basic rectification of batchnorm eliminating transdata. 2022-12-12 23:10:14 +08:00
王晓 e97e5ed2fa Add infershapeofNHWC to formathelper.
Signed-off-by: 王晓 <wangxiao99@huawei.com>
2022-12-12 14:54:33 +00:00
王晓 7d0e020038 Call Transpose explicitly in adapter of deformable_conv2d.
Signed-off-by: 王晓 <wangxiao99@huawei.com>
2022-12-12 14:26:22 +00:00
wangxiaoxin_sherie 57c068062d Add the aicore branch of indexput. 2022-12-12 21:14:20 +08:00
pipihugh 8497afbc67 Add the aicore branch of index. 2022-12-12 20:14:58 +08:00
weili10 50277fc97a update torch_npu/csrc/core/npu/register/OptionsManager.cpp.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-12 09:39:41 +00:00
xiaxia3 bd152ae9c9 Add tensor device verification 2022-12-12 10:54:30 +08:00
i-robot 5908caa6c6 !1813 Modify the error information of libhccl.so
Merge pull request !1813 from 詹昊/v1.8.1-3.0.0
2022-12-10 12:54:58 +00:00
zhanhao 39c1373934 Modify the error message reported when libhccl.so cannot be found. 2022-12-10 19:10:57 +08:00
i-robot 1d112602c3 !1787 ND default on for MatMul
Merge pull request !1787 from 唐超/v1.8.1-3.0.0
2022-12-10 09:08:43 +00:00
i-robot e3a6732327 !1809 [Feature] add aclrtCreateStreamWithConfig to create fast streams
Merge pull request !1809 from 王强/v1.8.1-3.0.0
2022-12-10 07:48:25 +00:00
i-robot 6316eeabb8 !1799 【BugFix】修复unique2申请空tensor的问题-3.0
Merge pull request !1799 from 戢芳/unique3.0
2022-12-10 07:16:25 +00:00
pipihugh a03ac753db Fixed the issue that unique2 applied for empty tensor 2022-12-10 14:30:12 +08:00
i-robot 6193332a63 !1800 [Feature] add aclrtCreateStreamWithConfig to create fast streams
Merge pull request !1800 from 王强/master
2022-12-10 14:17:03 +08:00
i-robot 329788183e !1793 AsStrided + Transpose instead of AsStrided【商发】
Merge pull request !1793 from 刘嘉巍/v1.8.1-3.0.0
2022-12-10 02:38:10 +00:00
i-robot b2ec030dab !1798 【精度比对工具】增加序号映射
Merge pull request !1798 from 杜金航/v1.8.1-3.0.0
2022-12-10 01:58:08 +00:00
i-robot 0c60492bd7 !1796 taskqueue优化
Merge pull request !1796 from 詹昊/v1.8.1-3.0.0
2022-12-09 13:10:26 +00:00
dujinhang 2c9e79c777 精度比对工具增加序号 2022-12-09 17:36:43 +08:00
zhanhao db40d88649 optimize task_queue 2022-12-09 16:13:21 +08:00
i-robot 8ce6140b6c !1795 回退batchnorm算子适配修改
Merge pull request !1795 from weili10/revert-merge-1638-v1.8.1-3.0.0
2022-12-09 07:58:33 +00:00
weili10 554167543e 回退 'Pull Request !1638 : 【Feature】batchNorm参数format与输入一致-3.0' 2022-12-09 07:32:24 +00:00
i-robot f0015e8d69 !1789 【1.8.1算子适配】logsumexp算子适配
Merge pull request !1789 from 郑亚金/v1.8.1-3.0.0_zyj_1209_logsumexp
2022-12-09 07:20:33 +00:00
刘嘉巍 ffd17028e2 AsStrided + Transpose instead of AsStrided 2022-12-09 11:32:33 +08:00
chaoTANG570034 618e228e31 set nd default on 2022-12-09 11:12:20 +08:00
yangxiaorun f45fc228a1 !1790 【新增DEBUG日志】记录pytorch申请释放内存及缓存池使用情况
Merge pull request !1790 from yangxiaorun/cherry-pick-1670554314
2022-12-09 02:56:18 +00:00
yangxiaorun 4df4b1d021 fixed 2df5874 from https://gitee.com/yangxiaorun1/pytorch/pulls/1502
feat: add memory log for pytorch
2022-12-09 02:51:56 +00:00
hxf12345677 6198b7013b logsumexp算子适配 2022-12-09 10:27:48 +08:00
i-robot a4a586c099 !1721 _nnpack_spatial_convolution OpCommand重构-3.0
Merge pull request !1721 from 戢芳/ns_conv3.0
2022-12-09 01:32:31 +00:00
i-robot 5ce381ee29 !1742 【BugFix】sum规避int和bool型-3.0
Merge pull request !1742 from 戢芳/sum_debug3.0
2022-12-08 08:27:35 +00:00
i-robot faf4f8f4a1 !1774 【溢出检测工具】增加api层dump功能
Merge pull request !1774 from 杜金航/v1.8.1-3.0.0
2022-12-08 08:23:37 +00:00
i-robot d03d9902a5 !1772 [商分]RepeatInterleave 算子适配层 合入商分
Merge pull request !1772 from aikede/sf_reInleave
2022-12-08 03:59:28 +00:00
aikede ced11d481d [商分]RepeatInterleave 算子增加适配层 2022-12-08 11:26:27 +08:00
pipihugh 45f75b2d91 _nnpack_spatial_convolution OpCommand重构 2022-12-08 10:55:58 +08:00
dujinhang 22c866562a 溢出检测工具增加api层dump功能 2022-12-08 09:56:54 +08:00
i-robot e98fb3e7a9 !1748 syncbn相关适配clean code修改商分
Merge pull request !1748 from huangxinliang/v1.8.1-3.0.0
2022-12-06 10:53:04 +00:00
xinlianglalala 73ec4aa20a clean code 2022-12-06 14:05:56 +08:00
i-robot 29c4e3177e !1711 【BugFix】修复smooth_l1_loss_backward的beta-3.0
Merge pull request !1711 from 戢芳/smoothloss3.0
2022-12-06 02:48:04 +00:00
pipihugh e557a670f7 bugfix:修复smooth_l1_loss_backward的beta 2022-12-05 16:59:38 +08:00
i-robot ac2be3d4b3 !1724 亲和库限制说明
Merge pull request !1724 from 彭子荣/v1.8.1-3.0.0
2022-12-03 03:06:20 +00:00
i-robot 6b70ebc508 !1741 [feature] support npu tensortype, eg. torch.npu.FloatTensor
Merge pull request !1741 from shaoyf/feature/300/npu_tensortype
2022-12-03 02:36:20 +00:00
shaoyf 2a5c8d712c support npu tensortype eg. torch.npu.FloatTensor 2022-12-03 09:36:23 +08:00
i-robot 5ae140b269 !1744 syncbn算子优化适配
Merge pull request !1744 from huangxinliang/v1.8.1-3.0.0
2022-12-02 09:25:00 +00:00
pipihugh accf0ad0b9 sum规避int和bool型 2022-12-02 15:22:08 +08:00
xinlianglalala 901f7aa6a9 syncbn算子适配 2022-12-02 15:22:07 +08:00
i-robot 9846f84eb1 !1734 【序列化bugfix】避免_lagecy_save进行数据存储
Merge pull request !1734 from 闫鹏全/v1.8.1-3.0.0
2022-12-02 06:48:24 +00:00
pengzirong 2f362da467 亲和库增加限制说明
补充亲和库限制

优化器合并参数说明
2022-12-02 14:26:03 +08:00
i-robot f112fad7bf !1718 精度比对工具dump效率优化
Merge pull request !1718 from 杜金航/v1.8.1-3.0.0
2022-12-01 09:35:04 +00:00
dujinhang 67b833a230 精度比对工具dump效率优化 2022-12-01 17:01:50 +08:00
闫鹏全 d10fa4eac6 不支持legacy_save,采用zipfile的存储方式 2022-12-01 15:52:54 +08:00
i-robot 484bbfea80 !1712 补充亲和库局限性说明
Merge pull request !1712 from 王夏夏/v1.8.1-3.0.0
2022-11-30 11:27:17 +00:00
i-robot 7cb21ab5c9 !1704 【BugFix】sum保持self和result类型一致,且只规避bool型-3.0
Merge pull request !1704 from 戢芳/sum_debug3.0
2022-11-30 08:43:28 +00:00
weili10 988c67fe4a update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-11-30 06:39:29 +00:00
xiaxia3 02277f6bb8 补充亲和库局限性说明 2022-11-29 17:42:33 +08:00
i-robot be4930fb5e !1696 【序列化bugfix】解除cpu tensor加载时依赖torch_npu
Merge pull request !1696 from 闫鹏全/v1.8.1-3.0.0
2022-11-28 13:42:20 +00:00
i-robot cba848741e !1701 【BugFix】补充nllloss_2d的weight赋0的判断条件-3.0
Merge pull request !1701 from 戢芳/nllloss3.0
2022-11-26 12:49:00 +00:00
pipihugh de4619188c sum保持输入输出dtype一致,只规避bool型 2022-11-26 20:40:00 +08:00
pipihugh fff99b3219 补充nllloss_2d的weight赋0条件 2022-11-26 13:16:03 +08:00
i-robot c48f3c8406 !1678 增加溢出检测功能支持
Merge pull request !1678 from 杜金航/v1.8.1-3.0.0
2022-11-25 09:41:43 +00:00
15990042527 703047dd98 增加溢出检测功能 2022-11-25 14:25:52 +08:00
闫鹏全 783acb8bf1 解除torch.save中cpu tensor对torch_npu包的依赖 2022-11-25 09:39:21 +08:00
i-robot f1107b1799 !1643 【BugFix】sum统一转fp32计算-3.0
Merge pull request !1643 from 戢芳/sum_dtype3.0
2022-11-22 11:10:25 +00:00
i-robot ab33067954 !1638 【Feature】batchNorm参数format与输入一致-3.0
Merge pull request !1638 from 戢芳/bn3.0
2022-11-22 11:08:30 +00:00
pipihugh 33aff05f8b sum转fp32计算 2022-11-22 10:21:12 +08:00
i-robot 7dffeb3877 !1635 【BugFix】删除copy_tensor_host_to_device-3.0
Merge pull request !1635 from 戢芳/copy_tensor3.0
2022-11-22 01:52:23 +00:00
i-robot 546ed2b617 !1669 【BugFix】修复div输入dtype不同时计算错误问题(商分)
Merge pull request !1669 from 王晓/div_diff_dtype_3.0.0
2022-11-21 08:57:19 +00:00
pipihugh cd65e8be97 batchNorm参数format与输入一致,保证二进制场景功能正常 2022-11-21 16:46:15 +08:00
wangxiao c7ecb68fd9 fix div fifferent dtype 2022-11-21 14:44:46 +08:00
i-robot 5cf3dbb015 !1666 Bugfix & Performance optimize for UpsampleNearest2dKernelNpu(商发)
Merge pull request !1666 from 刘嘉巍/v1.8.1-3.0.0
2022-11-19 09:18:35 +00:00
刘嘉巍 1cf96d4ef5 bugfix of upsamplenearest2dkernel 2022-11-19 11:44:45 +08:00
i-robot 54f51718e3 !1627 修复bn3d format问题(商分)
Merge pull request !1627 from 王晓/bn3d_3.0.0
2022-11-18 09:24:54 +00:00
i-robot 1ea15096a4 !1658 bugfix: 修复DDP场景多进程场景创建文件失败问题
Merge pull request !1658 from 施博/v1.8-3
2022-11-18 09:11:15 +00:00
i-robot 499097c474 !1659 aoe: update op list for aoe
Merge pull request !1659 from 施博/v1.8-3_aor
2022-11-18 08:13:21 +00:00
i-robot 598a152b1c !1608 【Feature】conv类算子私有格式整改-3.0
Merge pull request !1608 from 戢芳/conv3.0
2022-11-18 08:07:29 +00:00
shibo19 c2de09166e update op list for aoe 2022-11-18 15:15:26 +08:00
shibo19 c8aff7cb3e 修复DDP场景多进程场景创建文件失败问题 2022-11-18 15:13:37 +08:00
wangxiao c5924abc19 fix bn3d format 2022-11-18 13:37:54 +08:00
i-robot 912a0494e6 !1652 Optimize performance of AsStrided(商发)
Merge pull request !1652 from 刘嘉巍/v1.8.1-3.0.0
2022-11-18 03:07:21 +00:00
刘嘉巍 b862c56315 optimize performance of AsStridedKernel 2022-11-18 09:29:03 +08:00
i-robot 5d3aa66939 !1594 新API清单更新
Merge pull request !1594 from 彭子荣/v1.8.1-3.0.0
2022-11-17 11:56:49 +00:00
i-robot 75d2a2a05b !1645 【序列化bugfix】序列化加载参数map_location支持npu device数据
Merge pull request !1645 from 闫鹏全/v1.8.1-3.0.0
2022-11-17 08:07:59 +00:00
i-robot 81030a0de6 !1612 【BugFix】删除indexput中的异步拷贝-3.0
Merge pull request !1612 from 戢芳/indexput_up3.0
2022-11-17 08:05:57 +00:00
闫鹏全 e3a0019cc2 torch.load适配支持npu device类型的入参 2022-11-17 15:05:34 +08:00
pipihugh fb1ed121b9 conv类算子私有格式整改 2022-11-17 14:05:02 +08:00
pengzirong 02af7db9a6 API清单更新 2022-11-17 12:03:37 +08:00
pipihugh a370d2c5ec bugfix:删除不合理的copy_tensor_host_to_device 2022-11-16 16:08:19 +08:00
i-robot 1fb16225e3 !1626 【fixbug】修复cat不支持空tensor问题(商分)
Merge pull request !1626 from 王晓/cat_null_3.0.0
2022-11-15 11:29:46 +00:00
i-robot a843b9e341 !1628 README更新
Merge pull request !1628 from Jializheng/v1.8.1-3.0.0
2022-11-15 11:10:03 +00:00
j00648035 84b648e708 update deepspeed readme 2022-11-15 17:27:59 +08:00
wangxiao 605bc33d1b fix cat null 3.0.0 2022-11-15 16:46:34 +08:00
i-robot b99ac6da04 !1614 【BugFix】修复conv调用sum_out的反向问题-3.0
Merge pull request !1614 from 戢芳/conv_sum3.0
2022-11-15 04:01:16 +00:00
i-robot cf83f8e254 !1621 [bugfix] 给torch.cuda.amp下的文件打上自动转换函数补丁,避免自动转换失败
Merge pull request !1621 from 王姜奔/v1.8.1-3.0.0
2022-11-14 13:15:22 +00:00
王姜奔 9d44cba582 update patch_cuda 2022-11-14 20:57:22 +08:00
weili10 32bc6aa8a5 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-11-14 08:58:49 +00:00
pipihugh a5261b8776 bugfix:修复conv调用sum_out的反向问题 2022-11-14 10:35:29 +08:00
pipihugh 291e32ad75 bugfix:删除indexput中的异步拷贝 2022-11-12 18:25:32 +08:00
i-robot a3f914ffff !1598 empty_with_format整改-商分
Merge pull request !1598 from 戢芳/empty_3.0
2022-11-12 08:59:59 +00:00
i-robot 4a1995885c !1607 [BugFix] Support npu:x format for Tensor.npu
Merge pull request !1607 from shaoyf/cherry-pick-1668161156
2022-11-11 11:37:59 +00:00
shaoyf 510bf64e08 fixed c39619f from https://gitee.com/shaoyf/pytorch/pulls/1606
Bugfix Support npu:x format for Tensor.npu
2022-11-11 10:05:56 +00:00
i-robot d9f9579c05 !1603 【序列化bugfix】兼容老版本的文件加载
Merge pull request !1603 from 闫鹏全/v1.8.1-3.0.0
2022-11-11 09:38:05 +00:00
闫鹏全 01f118eff5 兼容old_zipfile_serialization 2022-11-11 17:18:49 +08:00
i-robot c948c58690 !1591 【add】:新增torch._aminmax的npu适配
Merge pull request !1591 from 郭夏/add_aminmax
2022-11-11 09:16:00 +00:00
i-robot 789b74e496 !1588 【bugfix】: 修复mul在输入有scalar参数时(tensor * scalar)输出类型处理错误问题
Merge pull request !1588 from 郭夏/bugfix_mul
2022-11-11 09:14:02 +00:00
pipihugh bf2b9c1e70 empty_with_format整改 2022-11-11 16:21:03 +08:00
郭夏 2d19f7bcc4 新增_aminmax适配
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2022-11-11 08:04:15 +00:00
郭夏 be54a1ae16 修复mul在输入有scalar参数时(tensor * scalar)输出类型处理错误问题
Signed-off-by: 郭夏 <guoxia2@huawei.com>
2022-11-11 07:46:16 +00:00
i-robot 5821884d10 !1581 Independent storage_offset compile in AsStrided(商发)
Merge pull request !1581 from 刘嘉巍/v1.8.1-3.0.0
2022-11-11 03:36:06 +00:00
刘嘉巍 16b654d181 independent storage_offset compile in AsStrided 2022-11-11 09:27:34 +08:00
i-robot a15941b531 !1572 【BugFix】max支持不同dtype输入-商分
Merge pull request !1572 from 戢芳/max_3.0
2022-11-10 13:07:48 +00:00
i-robot 4c7d261c5d !1496 【图模式1.8】Basic module for asynchronous printing in graph mode (商发)
Merge pull request !1496 from 刘嘉巍/v1.8.1-3.0.0
2022-11-10 13:05:41 +00:00
i-robot d511986f8e !1549 README更新
Merge pull request !1549 from 彭子荣/v1.8.1-3.0.0
2022-11-10 13:03:51 +00:00
i-robot ad23aa3072 !1575 【序列化】npu serialization
Merge pull request !1575 from 闫鹏全/v1.8.1-3.0.0
2022-11-10 11:49:42 +00:00
刘嘉巍 069460e0b1 basic module for asynchronous pringting in graph mode 2022-11-10 15:39:00 +08:00
闫鹏全 8738fdf440 npu serialization 2022-11-10 15:22:05 +08:00
pipihugh 97b5cc3747 bugfix:max支持不同dtype输入 2022-11-10 13:50:04 +08:00
i-robot b9b78c4da4 !1568 【Feature】sum增加dimlist的校验-商分
Merge pull request !1568 from 戢芳/sum_3.0
2022-11-10 02:30:37 +00:00
pipihugh 794650ffb6 feature:sum添加dimlist校验 2022-11-10 09:22:13 +08:00
pengzirong f9d863f194 readme更新镜像版本配套表 2022-11-08 17:10:16 +08:00
i-robot 2a41383d6e !1538 API修正
Merge pull request !1538 from 彭子荣/v1.8.1-3.0.0
2022-11-08 03:47:09 +00:00
pengzirong ec151adbb7 API修正 2022-11-08 11:18:43 +08:00
i-robot 69a12427f2 !1522 [fix] do not support NZ tensor when rank<2
Merge pull request !1522 from 王强/v1.8.1-3.0.0
2022-11-05 08:17:27 +00:00
wq160 58611cfdc2 [fix] do not support NZ tensor when rank<2 2022-11-05 11:02:42 +08:00
weili10 76803d7a2e !1503 API支持清单更新
Merge pull request !1503 from 彭子荣/v1.8.1-3.0.0
2022-11-03 09:17:41 +00:00
pengzirong 32ea7725d6 API更新 2022-11-03 16:58:28 +08:00
i-robot 7d0b9dffb2 !1471 【BugFix】规避sum不支持bool类型-商分
Merge pull request !1471 from 戢芳/sum_bool_rc3
2022-10-28 10:48:51 +00:00
i-robot 58ce863f66 !1477 batchnorm性能优化
Merge pull request !1477 from shaoyf/cherry-pick-1666874862
2022-10-28 09:24:58 +00:00
pipihugh ed725f16f9 sum算子不支持bool,转bool规避rc3 2022-10-28 16:53:20 +08:00
i-robot 0a9db8d5bc !1479 [refactor] optimize contiguous op name, op: AsStrided ViewCopy
Merge pull request !1479 from xudaohong/v1.8.1-3.0.rc3
2022-10-28 08:04:52 +00:00
x00430237 1c335f3734 [refactor] optimize contiguous op name, AsStrided ViewCopy 2022-10-28 09:17:01 +08:00
shaoyf 15bb908e6d fixed e5f6878 from https://gitee.com/shaoyf/pytorch/pulls/1472
Change the dtype of num_batches_tracked in _NormBase from int64 to int32
2022-10-27 12:47:42 +00:00
i-robot 05d12f12cd !1465 [refactor] optimize contiguous op name
Merge pull request !1465 from xudaohong/v1.8.1-3.0.rc3
2022-10-27 02:40:49 +00:00
x00430237 b775c31dd6 [refactor] modify codecheck 2022-10-26 18:16:33 +08:00
x00430237 25d5ee5bb5 [refactor] modify test cases synchronously 2022-10-26 18:16:33 +08:00
x00430237 c0019d0c1c [refactor] optimize memory repoint contiguous op name 2022-10-26 18:16:33 +08:00
x00430237 cbb73d7d7d [refactor] optimize contiguous op name 2022-10-26 18:16:33 +08:00
i-robot 8e34f19670 !1463 [bugfix]cancel lstm npu_dtype_cast
Merge pull request !1463 from darin123/v1.8.1-3.0.rc3
2022-10-26 09:02:30 +00:00
anping 5aa01f8f74 [bugfix]cancel lstm npu_dtype_cast 2022-10-26 16:23:37 +08:00
i-robot aab1760132 !1462 【BugFix】sum适配重构-商分
Merge pull request !1462 from 戢芳/sum1.8_rc3
2022-10-26 08:06:28 +00:00
pipihugh 4aa5714e57 sum适配重构 2022-10-26 15:03:28 +08:00
i-robot 708daf9168 !1443 【refactor】npu_dtype_cast替换to方案
Merge pull request !1443 from darin123/v1.8.1-3.0.rc3
2022-10-26 06:16:39 +00:00
anping b55f60052b [refactor]npu_dtype_cast replace to function. 2022-10-24 11:22:45 +08:00
i-robot 58aabf5807 !1442 优化npu_dtype_cast
Merge pull request !1442 from 王夏夏/v1.8.1-3.0.rc3
2022-10-22 07:44:31 +00:00
xiaxia3 f884ffe7d4 优化npu_dtype_cast 2022-10-22 14:37:57 +08:00
weili10 a3265a868d update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-10-22 04:10:23 +00:00
i-robot e5deeac584 !1434 viewcopy修改入参编译选项
Merge pull request !1434 from 王晓/viewcopy_independent
2022-10-20 09:32:42 +00:00
i-robot 5ef79b6c4e !1427 【FixBug】修复index算子重复编译问题
Merge pull request !1427 from 王晓/index_indepdt
2022-10-20 09:20:39 +00:00
wangxiao 3bf4f83b66 viewcopy_independent 2022-10-20 16:57:35 +08:00
i-robot 5936da408a !1428 【feature】优化环境变量ACL_DUMP_DATA内部判定
Merge pull request !1428 from 汪瑞哲/v1.8.1-3.0.rc3
2022-10-20 07:53:47 +00:00
wang-ruizhe7 cb77c09b97 feat: Optimize option: ACL_DUMP_DATA
Change the internal implementation of this functions, using
const static to ensure that the GetBoolTypeOption func run only once.
2022-10-20 15:05:16 +08:00
wangxiao 3a67565f67 index outsize independent 2022-10-20 14:51:41 +08:00
i-robot 7fcb40495c !1423 【feature】新增环境变量DISABLE_ACLOP_COM_EXE
Merge pull request !1423 from 汪瑞哲/v1.8.1-3.0.rc3
2022-10-20 06:35:17 +00:00
wang-ruizhe7 1d12efd9b3 feat: Add env variable "DISABLE_ACLOP_COM_EXE"
1. This env variable can control whether op compile and execute
in single mode(with task queue or not).
2. Change the internal implementation of the three functions, using
   const static to ensure that the GetBoolTypeOption func run only once.
2022-10-20 11:32:10 +08:00
weili10 06fed4347b update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-10-20 01:50:32 +00:00
i-robot 0368c9d196 !1422 资料问题更新
Merge pull request !1422 from 彭子荣/v1.8.1-3.0.rc3
2022-10-19 12:09:47 +00:00
pengzirong 240df38f54 修改版本配套表&问题 2022-10-19 18:06:12 +08:00
i-robot 9f8a959b13 !1412 补充README图片
Merge pull request !1412 from 彭子荣/v1.8.1-3.0.rc3
2022-10-18 08:25:20 +00:00
pengzirong ea93144083 补充FAQ图 2022-10-18 09:31:44 +08:00
i-robot 88f3722a7e !1395 新增训练调优&工具使用指南
Merge pull request !1395 from 彭子荣/v1.8.1-3.0.rc3
2022-10-17 03:58:26 +00:00
i-robot 578699fe7c !1374 index indexput v3(商分)
Merge pull request !1374 from 王晓/rc3_index_v3_new
2022-10-15 03:07:41 +00:00
pengzirong c8e320840a 新增训练调优&工具使用指南 2022-10-14 18:45:03 +08:00
i-robot 10cda1bfcf !1384 【BugFix】mul去除多余copy操作 - 商分
Merge pull request !1384 from 戢芳/mulrc3
2022-10-14 06:22:49 +00:00
i-robot b51465ccc4 !1377 新增训练调优&工具使用指南
Merge pull request !1377 from 彭子荣/v1.8.1-3.0.rc3
2022-10-14 02:41:06 +00:00
pipihugh c35da010df bugfix:去除mul中多余的copy操作 2022-10-14 09:45:45 +08:00
pengzirong f42d1adbf2 新增训练调优&工具使用指南
1

1
2022-10-13 12:21:20 +08:00
wangxiao 60c876fccd index indexput v3 2022-10-12 20:18:23 +08:00
i-robot 85078b7a6d !1363 bugfix:torch.device for Module.to
Merge pull request !1363 from 王夏夏/v1.8.1-3.0.rc3
2022-10-09 13:21:59 +00:00
xiaxia3 0f30ce7c90 bugfix:torch.device for Module.to 2022-10-09 21:11:19 +08:00
i-robot 43b649c9c3 !1356 FAQs 文档修改,增加一条多卡初始化卡住的情况
Merge pull request !1356 from 龚俊强/v1.8.1-3.0.rc3
2022-10-09 03:00:23 +00:00
i-robot 0c3a39d2eb !1361 【bugfix】1.8版本显存性能劣化修正
Merge pull request !1361 from 闫鹏全/v1.8.1-3.0.rc3
2022-10-09 02:40:21 +00:00
闫鹏全 8e67bc79c5 NPU计算格式适配 2022-10-09 09:13:17 +08:00
i-robot 01525c8043 !1358 【bernoulli适配_商分】 bernoulli IR修改,适配层对齐 & cast 问题处理
Merge pull request !1358 from 沈鹏程/108_bernoulli_IR_shangfen
2022-10-08 14:15:50 +00:00
shenpengcheng 0560393277 IR修改适配层对齐 & cast问题处理 2022-10-08 21:39:02 +08:00
junqiang521 eaa979182e add FAQs 2022-10-08 19:39:08 +08:00
i-robot 105ce9b9b7 !1353 [Cleancode] Clean code for wrong import order.
Merge pull request !1353 from shaoyf/cherry-pick-1665219552
2022-10-08 10:36:52 +00:00
shaoyf 7cb2f3f615 fixed f296e85 from https://gitee.com/shaoyf/pytorch/pulls/1352
Clean code for wrong import order.
2022-10-08 08:59:13 +00:00
i-robot 2c599ad2ab !1351 二进制规避代码回退
Merge pull request !1351 from weili10/revert-merge-1342-v1.8.1-3.0.rc3
2022-10-08 08:59:06 +00:00
i-robot 5823172995 !1340 修复index中转连续走aicpu导致性能下降问题(商分)
Merge pull request !1340 from 王晓/rc3_index_mae
2022-10-08 07:46:54 +00:00
i-robot 3da9a07053 !1333 grid_sample2d适配层传参符合算子IR
Merge pull request !1333 from aikede/bug_grid_rc3
2022-10-08 07:44:57 +00:00
weili10 cfc3f32e02 回退 'Pull Request !1342 : BNTrainingUpdate在二进制场景下不使用inplace的running_mean与running_var' 2022-10-08 07:36:33 +00:00
wangxiao 6f29462a9b fix index bug 2022-10-08 14:30:25 +08:00
weili10 3e7c76d4f5 !1346 【BCM】合入index_put适配代码
Merge pull request !1346 from weili10/revert-merge-1345-v1.8.1-3.0.rc3
2022-10-07 15:04:47 +00:00
weili10 52c2074f92 回退 'Pull Request !1345 : 回退index_put算子bcm整改代码,解决带:输入场景性能劣化问题' 2022-10-07 14:18:17 +00:00
weili10 d02a477ee1 !1345 回退index_put算子bcm整改代码,解决带:输入场景性能劣化问题
Merge pull request !1345 from weili10/revert-merge-1320-v1.8.1-3.0.rc3
2022-10-07 14:11:24 +00:00
weili10 87ef723b94 回退 'Pull Request !1320 : 【BCM】index_put 适配(商发)' 2022-10-07 14:00:50 +00:00
施博 f4bb4b4b97 !1342 BNTrainingUpdate在二进制场景下不使用inplace的running_mean与running_var
Merge pull request !1342 from 郭鹏/v1.8.1-3.0.rc3
2022-10-06 07:14:13 +00:00
gp513 67cf4f85bf BNTrainingUpdate no inplace if jit_compile is false
bugfix
2022-10-06 14:56:26 +08:00
i-robot 195dab2fde !1336 修复index_select反向index_add不支持index为0维问题(商分)
Merge pull request !1336 from 王晓/rc3_index_select
2022-10-05 08:38:58 +00:00
wangxiao 9fa200d68d fix index_add 2022-09-30 18:00:23 +08:00
i-robot a7158a1929 !1332 【BugFix】修正HCCL报错信息不完整
Merge pull request !1332 from 汪瑞哲/v1.8.1-3.0.rc3
2022-09-30 06:11:27 +00:00
aikede 2fb5dc8a49 gridsample2d 传参符合算子IR 2022-09-30 11:53:58 +08:00
wang-ruizhe7 a23d501c29 fix: Fix HCCL error does not have complete error message
HCCL error does not show specific error code and error info, so add
AclGetErrMsg() interface in C10D_HCCL_CHECK macro to show more detailed
error message.
2022-09-30 10:26:36 +08:00
i-robot d988e05c1e !1320 【BCM】index_put 适配(商发)
Merge pull request !1320 from hxf12345677/indexrc3
2022-09-29 12:18:58 +00:00
i-robot 7004fdc8c1 !1322 【精度比对】backwardhook执行bug修复
Merge pull request !1322 from 闫鹏全/v1.8.1-3.0.rc3
2022-09-28 03:32:32 +00:00
i-robot 1ffbd2c529 !1324 回退processgrouphccl binding代码
Merge pull request !1324 from weili10/revert-merge-1306-v1.8.1-3.0.rc3
2022-09-28 03:30:25 +00:00
weili10 0ebd5bc2de 回退 'Pull Request !1306 : add ProcessGroupHCCL methods binding' 2022-09-28 03:05:43 +00:00
i-robot 2dab50e911 !1323 【BugFix】_unique2算子fp16场景存在精度问题,转fp32规避 - 商分
Merge pull request !1323 from 戢芳/unique1.8_rc3
2022-09-27 13:20:44 +00:00
闫鹏全 c378e36a49 修复正向计算result类型推断错误,导致的反向hook执行报错的问题 2022-09-27 20:04:43 +08:00
i-robot ae60dadb0c !1310 【图模式1.8】Disable DropoutKernel RNG state in graph mode
Merge pull request !1310 from 刘嘉巍/dev-rc3
2022-09-27 11:46:44 +00:00
i-robot b2471c6019 !1317 masked_select支持非bool mask(商分)
Merge pull request !1317 from 王晓/maskedselect_rc3
2022-09-27 11:44:43 +00:00
hxf12345677 f23017520f 【BCM】indexput 适配 2022-09-27 19:37:50 +08:00
pipihugh 59974ffb1f bugfix:_unique2算子fp16场景存在精度问题,转fp32规避 2022-09-27 19:31:40 +08:00
i-robot a4a74ef608 !1306 add ProcessGroupHCCL methods binding
Merge pull request !1306 from weili10/v1.8.1-3.0.rc3
2022-09-27 08:20:48 +00:00
i-robot 682f4916bc !1316 [Bugfix] Support npu:x format for Module.to.
Merge pull request !1316 from 尤安升/v1.8.1-3.0.rc3
2022-09-27 08:18:52 +00:00
wangxiao 98cacfd424 maskselect mask support no bool 2022-09-27 15:34:05 +08:00
尤安升 6fa6a82725 [Bugfix] Support npu:x format for Module.to. 2022-09-27 15:24:46 +08:00
刘嘉巍 3fb4baa9ae disable DropoutKernel rng state in graph mode 2022-09-27 11:01:19 +08:00
i-robot 4df3f6c129 !1254 【图模式1.8】adapt ops for graph mode & add testcase
Merge pull request !1254 from 刘嘉巍/dev-rc3
2022-09-27 02:54:38 +00:00
i-robot 87cd5ddc67 !1307 回退padv3grad适配(商发)
Merge pull request !1307 from hxf12345677/pav3
2022-09-27 01:40:34 +00:00
hxf12345677 4bb25f12a1 padv3grad 商发回退 2022-09-26 20:52:26 +08:00
i-robot 7670985e45 !1292 [Cleancode] clean code for all.
Merge pull request !1292 from shaoyf/v1.8.1_clean_code
2022-09-26 12:35:12 +00:00
i-robot 68b3519bba !1257 【BugFix】修复avgpool2d 算子输出shape错误问题, 对不支持三维输入做增维操作(商分)
Merge pull request !1257 from hxf12345677/avg
2022-09-26 12:33:14 +00:00
weili10 f2f1f86dc7 add ProcessGroupHCCL methods binding 2022-09-26 16:48:08 +08:00
shaoyf 61d0e69a87 adjust torch_npu import order 2022-09-26 10:26:11 +08:00
i-robot 4ffb7eb40a !1287 【BugFix】修正HCCL接口reduce标杆 - 商分
Merge pull request !1287 from 戢芳/reduce_rc3
2022-09-26 02:12:56 +00:00
i-robot a0316876e5 !1293 【BCM】删除triu、scatter_add的过适配 - 商分
Merge pull request !1293 from 戢芳/delete_rc3
2022-09-26 02:10:55 +00:00
尤安升 c0bcc5cb92 update scripts/codegen/templates/torch_funcs.py. 2022-09-24 07:07:11 +00:00
i-robot 8f8e68860e !1283 【BCM】upsample_nearest3d、upsample_trilinear3d删除过适配-商分
Merge pull request !1283 from 戢芳/upsample3d_rc3
2022-09-23 11:02:18 +00:00
i-robot 1f4e3405b9 !1284 【BCM】masked_scatter去除过适配-商分
Merge pull request !1284 from 戢芳/masked_scatter_rc3
2022-09-23 10:36:17 +00:00
i-robot fbc55e8ae5 !1295 【BugFix】cumprod IR参数变更- 商分
Merge pull request !1295 from 戢芳/cumprod_rc3
2022-09-23 10:34:14 +00:00
pipihugh bd74e86d31 cumprod 算子IR变更 2022-09-23 18:17:41 +08:00
i-robot 98dd3950e3 !1288 aoe支持算子列表刷新,dump算子同步刷新
Merge pull request !1288 from 施博/aoe_ops_rc3
2022-09-23 08:51:38 +00:00
pipihugh d9256f66f4 删除triu、scatter_add的过适配 2022-09-23 13:52:39 +08:00
shaoyf 7aec2ef7b3 clean code for all 2022-09-23 13:41:24 +08:00
shibo19 5455e9181f aoe支持算子列表刷新,dump算子同步刷新 2022-09-23 11:25:06 +08:00
pipihugh a3abdfeb01 bugfix:修正reduce的标杆 2022-09-22 21:00:49 +08:00
pipihugh a4457668f9 upsample_nearest3d、upsample_trilinear3d删除过适配 2022-09-22 14:09:27 +08:00
pipihugh 8ba5fbcae8 masked_scatter删除过适配 2022-09-22 14:06:51 +08:00
i-robot e5319854a4 !1266 nonzero第三类算子适配(商分)
Merge pull request !1266 from 王晓/rc3_nonzero
2022-09-21 02:54:38 +00:00
i-robot 1455dcdefb !1273 【BCM】upsample_nearest1d调用Resize-商分
Merge pull request !1273 from 戢芳/resize1.8_rc3
2022-09-20 13:38:34 +00:00
pipihugh 78c93d343a upsample_nearest1d调用Resize 2022-09-20 20:16:53 +08:00
i-robot 6e33590fe1 !1265 Modify randperm adapt to StatelessRandperm(商分)
Merge pull request !1265 from 王晓/rc3_randperm
2022-09-20 12:10:35 +00:00
i-robot 1ccb012c63 !1264 【BugFix】修复new_zeros、new_full、new_ones、new_tensor算子参数device='npu'报错问题
Merge pull request !1264 from shaoyf/bugfix_new_zeros
2022-09-20 12:08:34 +00:00
i-robot b66b9d76da !1259 【1.8.1算子适配】 MaskedSelect改为第三类算子适配(商分)
Merge pull request !1259 from hxf12345677/masked
2022-09-20 12:06:36 +00:00
hxf12345677 a27ed04728 修复avgpool2d 算子输出shape错误问题, 对不支持三维输入做增维操作 2022-09-19 20:19:49 +08:00
weili10 116a7637e9 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-09-19 11:26:07 +00:00
hxf12345677 26d8351efb MaskedSelect改为第三类算子适配 2022-09-19 14:47:13 +08:00
i-robot b8f7ebf540 !1263 index IR 变更(1.8商分)
Merge pull request !1263 from 王晓/rc3_index
2022-09-17 11:30:05 +00:00
shaoyf 7d20630d3e fix new_zeros new_full new_ones new_tensor when device='npu' 2022-09-17 18:43:37 +08:00
tianyumi 0e1635a3a5 randperm adapt to StatelessRandperm to support seed 2022-09-17 14:53:00 +08:00
tianyumi c1046a88a7 nonzero 3rd kind adapt 2022-09-17 14:47:08 +08:00
i-robot c68ff46887 !1253 【精度对比工具】文档更新
Merge pull request !1253 from 闫鹏全/master
2022-09-16 09:30:19 +00:00
刘嘉巍 6e4bd4b8d1 adapt ops for graph mode & add testcase 2022-09-16 16:47:48 +08:00
i-robot 3e6aa13e26 !1250 回退nllloss过适配
Merge pull request !1250 from 戢芳/back_nllloss
2022-09-16 04:06:09 +00:00
pipihugh 0cf1761227 回退nllloss过适配 2022-09-16 11:18:44 +08:00
闫鹏全 14a496d500 精度对比工具文档完善 2022-09-13 10:06:59 +08:00
596 changed files with 10590 additions and 27449 deletions
+2
View File
@@ -84,6 +84,7 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=redundant-decls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
# These flags are not available in GCC-4.8.5. Set only when using clang.
@@ -194,6 +195,7 @@ target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/lib
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libacl_op_compiler.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libge_runner.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libgraph.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libacl_tdt_channel.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC torch torch_cpu c10 python3.7m)
+30 -3
View File
@@ -1,12 +1,14 @@
approvers:
- blian
- nalinaly
- weili10
- you-ansheng
- yskhhh
- clinglai
- lvpeiyuan
reviewers:
- shibo19
- Ronnie_zheng
- xiaxia3
- li_chao10
- petissue
- td__lihan
- ascendzyj
@@ -20,4 +22,29 @@ reviewers:
- fairwarning
- you-ansheng
- yinzijun
- weili10
- weili10
- granpad7
- clinglai
- shaoyf
- yanpengquan07
- xiong05
- liu-jiaweikf
- xiepeng20
- brightlyking
- chenhao_1209
- wbigat
- will-devil
- ckirchhoff
- liu-tianlong
- jayshu
- lvpeiyuan
- luyoubing
- dai-yuwen
- jia8liang
- w_a_n_g_q_i
- simonzhouchun
- luo-hui46
- yang-renfeihuawei
- y00580292
- AllenYaWang
- lidezhao1
+5
View File
@@ -488,6 +488,11 @@ To verify the torch_npu reference, switch to another directory. If you perform t
<img src="figures/FAQ torch_npu.png" style="zoom:150%;" />
## Multi card training is stuck in initialization stage until timeout
IPv6 address is used in the "init_process_group" function of multi card communication, for example ::1 (Note that localhost may point to IPv6 address)
Use IPv4 to avoid this problem
# Version Description
For details, see [Release Notes](https://gitee.com/ascend/pytorch/tree/master/docs/en/RELEASENOTE).
+388 -166
View File
@@ -3,163 +3,241 @@
本项目开发了PyTorch Adapter插件,用于昇腾适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。用户在准备相关环境进行基于PyTorch框架模型的开发、运行时,可以选择在服务器中手动编译相关模块。
<h2 id="md">前提条件</h2>
- 需完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南》。
- Python支持版本为3.7.5、3.8、3.9。
# 文档
# 系统依赖库
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[昇腾社区PyTorch Adapter](https://www.hiascend.com/software/ai-frameworks/commercial)。
## CentOS & EulerOS
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git dos2unix
yum install -y gcc==7.3.0 cmake==3.12.0
## Ubuntu
apt-get install -y patch 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 dos2unix libopenblas-dev git dos2unix
apt-get install -y gcc==7.3.0 cmake==3.12.0
| 文档名称 | 文档链接 |
| -------------------------- | ------------------------------------------------------------ |
| PyTorch 安装指南 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/601/envdeployment/instg/instg_000035.html) |
| PyTorch 网络模型迁移和训练 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/601/modeldevpt/ptmigr/ptmigr_0001.html) |
| PyTorch 在线推理 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/601/modeldevpt/ptonlineinfer/ptonlineinfer_000001.html) |
| PyTorch 算子适配 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/601/operatordev/operatordevg/atlasopdev_10_0081.html) |
| PyTorch API清单 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/601/oplist/fwoperator/fwoperatorlist_0301.html) |
# 快速安装PyTorch
昇腾开发PyTorch Adapter插件用于适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力,本章节指导用户安装PyTorch框架和PyTorch Adapter插件。
**对应分支代码包下载<a name="zh-cn_topic_0000001435374593_section5248152713711"></a>**
>![](figures/icon-note.gif) **说明:**
>若安装gcc与cmake依赖命令报错,请参考FAQ使用源码安装。
>PyTorch配套的Python版本是:Python3.7.x(3.7.5\~3.7.11)、Python3.8.x(3.8.0\~3.8.11)、Python3.9.x(3.9.0\~3.9.2)。
安装PyTorch时,请参见[表1](#zh-cn_topic_0000001435374593_table723553621419)下载对应分支代码包。
**表 1** Ascend配套软件
# Ascend配套软件
| AscendPyTorch版本 | CANN版本 | 支持PyTorch版本 | Gitee分支名称 |
| :------------ | :----------- | :----------- | ------------- |
| 2.0.2 | CANN 5.0.2 | 1.5.0.post2 | 2.0.2.tr5 |
| 2.0.3 | CANN 5.0.3 | 1.5.0.post3 | 2.0.3.tr5 |
| 2.0.4 | CANN 5.0.4 | 1.5.0.post4 | 2.0.4.tr5 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
<a name="zh-cn_topic_0000001435374593_table723553621419"></a>
# 安装方式
## 安装Pytorch依赖环境
如果使用非root用户安装,用户需要在本步骤的每句命令后加**--user**,示例如:pip3 install pyyaml --user。
```sh
pip3 install pyyaml
pip3 install wheel
```
## 编译安装PyTorch和昇腾插件
首先安装官方torch包,然后编译安装插件。
```sh
#x86_64
pip3 install torch==1.8.1+cpu #若使用pip命令安装cpu版本PyTorch报错,请手动下载whl包安装,下载地址:(https://download.pytorch.org/whl/torch)
#aarch64
#社区未提供arm架构cpu安装包,请参见FAQ第一条,使用源码编译安装pytorch
```
编译生成pytorch插件的二进制安装包。
```
# 下载master分支代码,进入插件根目录
git clone -b master https://gitee.com/ascend/pytorch.git
cd pytorch
# 指定python版本编包方式:
bash ci/build.sh --python=3.7
# 或
bash ci/build.sh --python=3.8
# 或
bash ci/build.sh --python=3.9
```
然后安装pytorch/dist下生成的插件torch_npu包,{arch}为架构名称。
```
pip3 install --upgrade dist/torch_npu-1.8.1rc2-cp37-cp37m-linux_{arch}.whl
```
下载torchvision。
```
pip3 install torchvision==0.9.1
```
# 运行
## 运行环境变量
在当前仓库根目录中执行设置环境变量脚本
```
source env.sh
```
## 自定义环境变量
可选的环境变量可能会对运行的模型产生影响:
```
export COMBINED_ENABLE=1 # 非连续转连续二级推导优化,可选,开启设置为1。当模型中有大量AsStrided高耗时算子被调用时,可以尝试开启此优化以获得潜在的device执行效率的提升。
export ACL_DUMP_DATA=1 # 算子数据dump功能,调试时使用,可选,开启设置为1
```
**表 1** 环境变量说明
<a name="zh-cn_topic_0000001152616261_table42017516135"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001152616261_p51981251161315"><a name="zh-cn_topic_0000001152616261_p51981251161315"></a><a name="zh-cn_topic_0000001152616261_p51981251161315"></a>配置项</p>
<table><thead align="left"><tr id="zh-cn_topic_0000001435374593_row723593618147"><th class="cellrowborder" valign="top" width="18.16%" id="mcps1.2.6.1.1"><p id="zh-cn_topic_0000001435374593_p12634164910142"><a name="zh-cn_topic_0000001435374593_p12634164910142"></a><a name="zh-cn_topic_0000001435374593_p12634164910142"></a>AscendPyTorch版本</p>
</th>
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001152616261_p9198135114133"><a name="zh-cn_topic_0000001152616261_p9198135114133"></a><a name="zh-cn_topic_0000001152616261_p9198135114133"></a>说明</p>
<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>
<th class="cellrowborder" valign="top" width="15.78%" id="mcps1.2.6.1.2"><p id="zh-cn_topic_0000001435374593_p7634174921415"><a name="zh-cn_topic_0000001435374593_p7634174921415"></a><a name="zh-cn_topic_0000001435374593_p7634174921415"></a>CANN版本</p>
</th>
<th class="cellrowborder" valign="top" width="17.080000000000002%" id="mcps1.2.6.1.3"><p id="zh-cn_topic_0000001435374593_p36341149111412"><a name="zh-cn_topic_0000001435374593_p36341149111412"></a><a name="zh-cn_topic_0000001435374593_p36341149111412"></a>支持PyTorch版本</p>
</th>
<th class="cellrowborder" valign="top" width="17.05%" id="mcps1.2.6.1.4"><p id="zh-cn_topic_0000001435374593_p163414971418"><a name="zh-cn_topic_0000001435374593_p163414971418"></a><a name="zh-cn_topic_0000001435374593_p163414971418"></a>代码分支名称</p>
</th>
<th class="cellrowborder" valign="top" width="31.929999999999996%" id="mcps1.2.6.1.5"><p id="p99351717112212"><a name="p99351717112212"></a><a name="p99351717112212"></a>AscendHub镜像版本/名称(<a href="https://ascendhub.huawei.com/#/index" target="_blank" rel="noopener noreferrer">获取链接</a>)</p>
</th>
</tr>
</thead>
<tbody><tr id="row1452975217222"><td class="cellrowborder" rowspan="3" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p1849173117229"><a name="p1849173117229"></a><a name="p1849173117229"></a>3.0.0</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>(可选)非连续转连续二级推导优化,开启设置为1。当模型中有大量AsStrided高耗时算子被调用时,可以尝试开启此优化以获得潜在的device执行效率的提升。但是Host下发性能存在下降风险。</p>
<td class="cellrowborder" rowspan="3" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p13849183142218"><a name="p13849183142218"></a><a name="p13849183142218"></a>CANN 6.0.1</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p197571831182710"><a name="p197571831182710"></a><a name="p197571831182710"></a>1.5.0.post8</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p18655452182620"><a name="p18655452182620"></a><a name="p18655452182620"></a>v1.5.0-3.0.0</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p2087128165411"><a name="p2087128165411"></a><a name="p2087128165411"></a>22.0.0/pytorch-modelzoo</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>
<tr id="row16995654102215"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p48506347263"><a name="p48506347263"></a><a name="p48506347263"></a>1.8.1</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>(可选)算子数据dump功能,调试时使用,开启设置为1。</p>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p10655452142612"><a name="p10655452142612"></a><a name="p10655452142612"></a>v1.8.1-3.0.0</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p2087118825410"><a name="p2087118825410"></a><a name="p2087118825410"></a>22.0.0-1.8.1/pytorch-modelzoo</p>
</td>
</tr>
<tr id="row6631331153118"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p20696104313275"><a name="p20696104313275"></a><a name="p20696104313275"></a>1.11.0.rc2(beta)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p156551352122620"><a name="p156551352122620"></a><a name="p156551352122620"></a>v1.11.0-3.0.0</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p587113885411"><a name="p587113885411"></a><a name="p587113885411"></a>-</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row423610361140"><td class="cellrowborder" rowspan="3" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p597121514227"><a name="p597121514227"></a><a name="p597121514227"></a>3.0.rc3</p>
</td>
<td class="cellrowborder" rowspan="3" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p69712015122215"><a name="p69712015122215"></a><a name="p69712015122215"></a>CANN 6.0.RC1</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p89718154228"><a name="p89718154228"></a><a name="p89718154228"></a>1.5.0.post7</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p139712015142217"><a name="p139712015142217"></a><a name="p139712015142217"></a>v1.5.0-3.0.rc3</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p587138125420"><a name="p587138125420"></a><a name="p587138125420"></a>22.0.RC3/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row72366365141"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p39711715202219"><a name="p39711715202219"></a><a name="p39711715202219"></a>1.8.1.rc3</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p159721515162214"><a name="p159721515162214"></a><a name="p159721515162214"></a>v1.8.1-3.0.rc3</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p17935111716221"><a name="p17935111716221"></a><a name="p17935111716221"></a>22.0.RC3-1.8.1/pytorch-modelzoo</p>
</td>
</tr>
<tr id="row14248651114319"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p117920554298"><a name="p117920554298"></a><a name="p117920554298"></a>1.11.0.rc1(beta)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p10179125515298"><a name="p10179125515298"></a><a name="p10179125515298"></a>v1.11.0-3.0.rc3</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p7179115512292"><a name="p7179115512292"></a><a name="p7179115512292"></a>-</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row823643641415"><td class="cellrowborder" rowspan="2" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p8972131519223"><a name="p8972131519223"></a><a name="p8972131519223"></a>3.0.rc2</p>
</td>
<td class="cellrowborder" rowspan="2" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p9972915202212"><a name="p9972915202212"></a><a name="p9972915202212"></a>CANN 5.1.RC2</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p18972215192215"><a name="p18972215192215"></a><a name="p18972215192215"></a>1.5.0.post6</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p17972111510220"><a name="p17972111510220"></a><a name="p17972111510220"></a>v1.5.0-3.0.rc2</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p79355171226"><a name="p79355171226"></a><a name="p79355171226"></a>22.0.RC2/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row17236133611148"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p7972101514227"><a name="p7972101514227"></a><a name="p7972101514227"></a>1.8.1.rc2</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p1897217155228"><a name="p1897217155228"></a><a name="p1897217155228"></a>v1.8.1-3.0.rc2</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p109351117122215"><a name="p109351117122215"></a><a name="p109351117122215"></a>22.0.RC2-1.8.1/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row17237123610141"><td class="cellrowborder" rowspan="2" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p169723153221"><a name="p169723153221"></a><a name="p169723153221"></a>3.0.rc1</p>
</td>
<td class="cellrowborder" rowspan="2" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p159721915182216"><a name="p159721915182216"></a><a name="p159721915182216"></a>CANN 5.1.RC1</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p18972815162217"><a name="p18972815162217"></a><a name="p18972815162217"></a>1.5.0.post5</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p79721155222"><a name="p79721155222"></a><a name="p79721155222"></a>v1.5.0-3.0.rc1</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p20935131722217"><a name="p20935131722217"></a><a name="p20935131722217"></a>22.0.RC1/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row0237103681420"><td class="cellrowborder" valign="top" headers="mcps1.2.6.1.1 "><p id="p897216157226"><a name="p897216157226"></a><a name="p897216157226"></a>1.8.1.rc1</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.2 "><p id="p1972101515223"><a name="p1972101515223"></a><a name="p1972101515223"></a>v1.8.1-3.0.rc1</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.6.1.3 "><p id="p16935151722212"><a name="p16935151722212"></a><a name="p16935151722212"></a>-</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row15574104531416"><td class="cellrowborder" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p99721715182217"><a name="p99721715182217"></a><a name="p99721715182217"></a>2.0.4</p>
</td>
<td class="cellrowborder" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p2097281518228"><a name="p2097281518228"></a><a name="p2097281518228"></a>CANN 5.0.4</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p1297218156226"><a name="p1297218156226"></a><a name="p1297218156226"></a>1.5.0.post4</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p15973915192218"><a name="p15973915192218"></a><a name="p15973915192218"></a>2.0.4.tr5</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p193515171225"><a name="p193515171225"></a><a name="p193515171225"></a>21.0.4/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row14742104715146"><td class="cellrowborder" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p149734151227"><a name="p149734151227"></a><a name="p149734151227"></a>2.0.3</p>
</td>
<td class="cellrowborder" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p1397317155220"><a name="p1397317155220"></a><a name="p1397317155220"></a>CANN 5.0.3</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p79734156229"><a name="p79734156229"></a><a name="p79734156229"></a>1.5.0.post3</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p997341592219"><a name="p997341592219"></a><a name="p997341592219"></a>2.0.3.tr5</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p193551715225"><a name="p193551715225"></a><a name="p193551715225"></a>21.0.3/pytorch-modelzoo</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001435374593_row17748104281412"><td class="cellrowborder" valign="top" width="18.16%" headers="mcps1.2.6.1.1 "><p id="p797371515225"><a name="p797371515225"></a><a name="p797371515225"></a>2.0.2</p>
</td>
<td class="cellrowborder" valign="top" width="15.78%" headers="mcps1.2.6.1.2 "><p id="p20973615192217"><a name="p20973615192217"></a><a name="p20973615192217"></a>CANN 5.0.2</p>
</td>
<td class="cellrowborder" valign="top" width="17.080000000000002%" headers="mcps1.2.6.1.3 "><p id="p1997314151227"><a name="p1997314151227"></a><a name="p1997314151227"></a>1.5.0.post2</p>
</td>
<td class="cellrowborder" valign="top" width="17.05%" headers="mcps1.2.6.1.4 "><p id="p697311512219"><a name="p697311512219"></a><a name="p697311512219"></a>2.0.2.tr5</p>
</td>
<td class="cellrowborder" valign="top" width="31.929999999999996%" headers="mcps1.2.6.1.5 "><p id="p693510174221"><a name="p693510174221"></a><a name="p693510174221"></a>21.0.2/pytorch-modelzoo</p>
</td>
</tr>
</tbody>
</table>
**安装PyTorch环境依赖<a name="section311512324315"></a>**
执行如下命令安装。如果使用非root用户安装,需要在命令后加**--user**,例如:**pip3 install pyyaml --user,pip3 install wheel --user**。
## 执行单元测试脚本
验证运行, 输出结果OK
```shell
cd test/test_network_ops/
python3 test_div.py
```
pip3 install pyyaml
pip3 install wheel
```
# 安装混合精度模块(可选)
**安装PyTorch<a name="section1762728142316"></a>**
AscendPyTorch1.8.1集成了AMP模块,也可用于混合精度训练等应用场景,与Apex模块的区别如下,请用户根据功能需要选择使用,若需安装Apex模块请参考相关[README文档](https://gitee.com/ascend/apex)进行编译安装Apex模块。
推荐用户使用编好的二进制whl包安装PyTorch 1.8.1。用户也可选择编译安装方式安装PyTorch 1.8.1。请参考[编译安装PyTorch](#使用源码编译安装PyTorch框架)。
- AMP
- 动态loss scale:动态计算loss scale的值并判断是否溢出。
- 不支持tensor融合功能。
1. 安装官方torch包。
- APEX
- x86\_64
- O1配置模式:Conv,Matmul等使用float16精度计算,其他如softmax、BN使用float32精度。
- O2配置模式:除BN使用float32精度外,其他部分使用float16精度。
- 静态loss scale:静态设置参数确保混合精度训练收敛。
- 动态loss scale:动态计算loss scale的值并判断是否溢出。
```
pip3 install torch==1.8.1+cpu
```
若执行以上命令安装cpu版本PyTorch报错,请点击下方PyTorch官方链接下载whl包安装。
PyTorch 1.8.1版本:[下载链接](https://download.pytorch.org/whl/cpu/torch-1.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl)。
- aarch64
1. 进入安装目录,执行如下命令获取鲲鹏文件共享中心上对应版本的whl包。
```
# 安装1.8.1版本
wget https://repo.huaweicloud.com/kunpeng/archive/Ascend/PyTorch/torch-1.8.1-cp37-cp37m-linux_aarch64.whl
```
2. 执行如下命令安装。如果使用非root用户安装,需要在命令后加**--user。**
```
# 安装1.8.1版本
pip3 install torch-1.8.1-cp37-cp37m-linux_aarch64.whl
```
# 文档
2. 安装PyTorch插件torch\_npu。以下命令以在aarch64架构下安装为例。
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[用户文档](docs/zh)。
1. 进入安装目录,执行如下命令获取PyTorch插件的whl包。
```
# 若用户在x86架构下安装插件,请将命令中文件包名中的“aarch64”改为“x86_64”。
wget https://gitee.com/ascend/pytorch/releases/download/v3.0.0-pytorch1.8.1/torch_npu-1.8.1-cp37-cp37m-linux_aarch64.whl
```
2. 执行如下命令安装。如果使用非root用户安装,需要在命令后加**--user。**
```
# 若用户在x86架构下安装插件,请将命令中文件包名中的“aarch64”改为“x86_64”。
pip3 install torch_npu-1.8.1-cp37-cp37m-linux_aarch64.whl
```
3. 安装对应框架版本的torchvision。
```
#PyTorch 1.8.1需安装0.9.1版本
pip3 install torchvision==0.9.1
```
**安装APEX混合精度模块<a name="section154215015416"></a>**
混合精度训练是在训练时混合使用单精度(float32)与半精度\(float16\)数据类型,将两者结合在一起,并使用相同的超参数实现了与float32几乎相同的精度。在迁移完成、训练开始之前,基于NPU芯片的架构特性,用户需要开启混合精度,可以提升模型的性能。APEX混合精度模块是一个集优化性能、精度收敛于一身的综合优化库,可以提供不同场景下的混合精度训练支持。APEX模块的使用介绍可参考《[PyTorch 网络模型迁移和训练指南](https://www.hiascend.com/document/detail/zh/canncommercial/601/modeldevpt/ptmigr/ptmigr_0001.html)》中的“混合精度说明“章节。
请参见[apex: Ascend apex adapter - Gitee.com](https://gitee.com/ascend/apex/tree/v1.8.1-3.0.0/)安装混合精度模块。
# 建议与交流
@@ -181,42 +259,142 @@ Ascend PyTorch的版本分支有以下几种维护阶段:
| **分支名** | **当前状态** | **上线时间** | **后续状态** | **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 | |
| **v2.0.2** | EOL | 2021-07-29 | N/A | |
| **v2.0.3** | EOL | 2021-10-15 | N/A | |
| **v2.0.4** | Unmaintained | 2022-01-15 | EOL <br> 2023-04-15 estimated | |
| **v3.0.rc1** | Maintained | 2022-04-10 | Unmaintained <br> 2023-04-10 estimated | |
| **v3.0.rc2** | Maintained | 2022-07-15 | Unmaintained <br> 2023-07-15 estimated | |
| **v3.0.rc3** | Maintained | 2022-10-20 | Unmaintained <br> 2023-10-20 estimated | |
| **v3.0.0** | Maintained | 2023-1-18 | Unmaintained <br> 2024-1-18 estimated | |
# FAQ
## CPU架构为ARM架构时,由于社区未提供ARM架构CPU版本的torch包,无法使用PIP3命令安装PyTorch1.8.1,需要使用源码编译安装。
## 使用PyTorch原生框架在ARM CPU上算子计算结果异常
下载PyTorch v1.8.1源码包。
当前使用的PyTorch官方原生框架在ARM CPU上运行时,算子计算结果会出现异常,此问题为原生框架社区的已知问题,详细内容可参考PyTorch官方社区[ISSUE](https://github.com/pytorch/pytorch/issues/75411)。
可通过以下方式解决:
- 修改算子输入数据类型,使用float64数据类型进行运算。
- 升级编译arm版本PyTorch使用的gcc编译器至9.4版本及以上,并使用相同编译器重新编译torch_npu、apex、mmcv等其他配套软件(避免因编译器版本不匹配导致兼容性问题)。
## 使用源码编译安装PyTorch框架。
**安装依赖<a name="section1832663918540"></a>**
选择编译安装方式安装时需要安装系统依赖。此处以CentOS与Ubuntu操作系统为例目前支持CentOS与Ubuntu操作系统。
EulerOS、OpenEuler、BCLinux、Kylin、UOS20 1020e系统可参考CentOS进行安装。
Debian、UOS20、UOS20 SP1、Linx系统可参考Ubuntu进行安装。
- CentOS
```
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git
yum install -y gcc==7.3.0 cmake==3.12.0 #gcc7.3.0版本及以上,cmake3.12.0版本及以上。
```
- Ubuntu
```
apt-get install -y patch 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 dos2unix libopenblas-dev git
apt-get install -y gcc==7.3.0 cmake==3.12.0 #gcc7.3.0版本及以上,cmake3.12.0版本及以上。
```
**安装PyTorch 1.8.1<a name="section462918122313"></a>**
以下操作步骤以安装PyTorch 1.8.1版本为例。
1. 安装官方torch包。
- x86\_64
```
pip3 install torch==1.8.1+cpu
```
若执行以上命令安装cpu版本PyTorch报错,请点击下方PyTorch官方链接下载whl包安装。
PyTorch 1.8.1版本:[下载链接](https://download.pytorch.org/whl/cpu/torch-1.8.1%2Bcpu-cp37-cp37m-linux_x86_64.whl)。
- 在aarch64架构下,用户可以选择编译安装官方torch包。
1. 下载PyTorch v1.8.1源码包。
```
git clone -b v1.8.1 https://github.com/pytorch/pytorch.git --depth=1 pytorch_v1.8.1
```
2. 进入源码包获取被动依赖代码。
```
cd pytorch_v1.8.1
git submodule sync
git submodule update --init --recursive
```
3. 配置环境变量。
```
export USE_XNNPACK=0
```
4. 执行编译安装。
```
python3 setup.py install
```
**安装torch_npu**
1. 编译生成PyTorch插件的二进制安装包。
```
# 下载对应PyTorch版本分支代码,进入插件根目录,以v1.8.1-3.0.0为例
git clone -b v1.8.1-3.0.0 https://gitee.com/ascend/pytorch.git
cd pytorch
# 指定Python版本编包方式,以Python3.7为例,其他Python版本请使用 --python=3.8或--python3.9
bash ci/build.sh --python=3.7
```
2. 安装pytorch/dist目录下生成的插件torch\_npu包,如果使用非root用户安装,需要在命令后加**--user**。
```
pip3 install --upgrade dist/torch_npu-1.8.1-cp37-cp37m-linux_aarch64.whl
# 若用户在x86架构下安装插件请替换为对应的whl包。
```
3. 安装对应框架版本的torchvision。
```
#PyTorch 1.8.1需安装0.9.1版本
pip3 install torchvision==0.9.1
```
4. 配置环境变量,验证是否安装成功。
1. 配置CANN环境变量脚本。
```
source <CANN软件安装目录>/<CANN软件路径>/set_env.sh
```
环境变量脚本的默认路径一般为:/usr/local/Ascend/ascend-toolkit/set_env.sh,其中ascend-toolkit路径取决于安装的CANN软件名称。
2. 执行单元测试脚本,验证PyTorch是否安装成功。
```
cd test/test_network_ops/
python3 test_div.py
```
结果显示OK证明PyTorch框架与插件安装成功。
## 在PIP设置为华为源时,安装requirements.txt中的typing依赖后,会导致python环境错误。
在PIP设置为华为源时,需打开requirements.txt文件,删除typing依赖,再执行命令。
```
git clone -b v1.8.1 https://github.com/pytorch/pytorch.git --depth=1 pytorch_v1.8.1
```
进入源码包获取被动依赖代码。
```
cd pytorch_v1.8.1
git submodule sync
git submodule update --init --recursive
```
执行编译安装。
```
python3 setup.py install
```
## 在PIP设置为华为源时,安装requirments.txt中的typing依赖后,会导致python环境错误。
在PIP设置为华为源时,需打开requirments.txt文件,删除typing依赖,再执行命令。
```
pip3 install -r requirments.txt
pip3 install -r requirements.txt
```
## 编译过程执行bash build.sh报错no module named yaml/typing_extensions.
@@ -324,7 +502,7 @@ pip3 install --upgrade te-0.4.0-py3-none-any.whl
以下步骤请在root用户下执行。
1. 下载gcc-7.3.0.tar.gz,下载地址为[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)。
1. 下载gcc-7.5.0.tar.gz,下载地址为[https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.gz)。
2. 安装gcc时候会占用大量临时空间,所以先执行下面的命令清空/tmp目录:
@@ -348,20 +526,20 @@ pip3 install --upgrade te-0.4.0-py3-none-any.whl
4. 编译安装gcc。
1. 进入gcc-7.3.0.tar.gz源码包所在目录,解压源码包,命令为:
1. 进入gcc-7.5.0.tar.gz源码包所在目录,解压源码包,命令为:
```
tar -zxvf gcc-7.3.0.tar.gz
tar -zxvf gcc-7.5.0.tar.gz
```
2. 进入解压后的文件夹,执行如下命令下载gcc依赖包:
```
cd gcc-7.3.0
cd gcc-7.5.0
./contrib/download_prerequisites
```
如果执行上述命令报错,需要执行如下命令在“gcc-7.3.0/“文件夹下下载依赖包:
如果执行上述命令报错,需要执行如下命令在“gcc-7.5.0/“文件夹下下载依赖包:
```
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
@@ -381,20 +559,20 @@ pip3 install --upgrade te-0.4.0-py3-none-any.whl
3. <a name="zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310"></a>执行配置、编译和安装命令:
```
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.5.0
make -j15 # 通过grep -w processor /proc/cpuinfo|wc -l查看cpu数,示例为15,用户可自行设置相应参数。
make install
```
>![](figures/icon-notice.gif) **须知:**
>其中“--prefix“参数用于指定linux\_gcc7.3.0安装路径,用户可自行配置,但注意不要配置为“/usr/local“及“/usr“,因为会与系统使用软件源默认安装的gcc相冲突,导致系统原始gcc编译环境被破坏。示例指定为“/usr/local/linux\_gcc7.3.0“。
>其中“--prefix“参数用于指定linux\_gcc7.5.0安装路径,用户可自行配置,但注意不要配置为“/usr/local“及“/usr“,因为会与系统使用软件源默认安装的gcc相冲突,导致系统原始gcc编译环境被破坏。示例指定为“/usr/local/linux\_gcc7.5.0“。
4. 修改软连接。
```
ln -s ${install_path}/gcc-7.3.0/bin/gcc /usr/bin/gcc
ln -s ${install_path}/gcc-7.3.0/bin/g++ /usr/bin/g++
ln -s ${install_path}/gcc-7.3.0/bin/c++ /usr/bin/c++
ln -s ${install_path}/gcc-7.5.0/bin/gcc /usr/bin/gcc
ln -s ${install_path}/gcc-7.5.0/bin/g++ /usr/bin/g++
ln -s ${install_path}/gcc-7.5.0/bin/c++ /usr/bin/c++
```
5.配置环境变量。
@@ -405,7 +583,7 @@ pip3 install --upgrade te-0.4.0-py3-none-any.whl
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
```
其中$\{install\_path\}为[3.](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310)中配置的gcc7.3.0安装路径,本示例为“/usr/local/gcc7.3.0/“。
其中$\{install\_path\}为[3.](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310)中配置的gcc7.5.0安装路径,本示例为“/usr/local/gcc7.5.0/“。
>![](figures/icon-note.gif) **说明:**
>本步骤为用户在需要用到gcc升级后的编译环境时才配置环境变量。
@@ -413,7 +591,7 @@ pip3 install --upgrade te-0.4.0-py3-none-any.whl
若存在pytorch编译不过,请检查软连接的库是否正确。
libstdc++->libstdc++.so.6.0.24(7.3.0)
libstdc++->libstdc++.so.6.0.24(7.5.0)
## 找不到libblas.so问题
@@ -485,7 +663,7 @@ warning如下图所示,由Tensor.set_data浅拷贝操作触发。主要原因
该warning不影响模型的精度和性能,可以忽略。
待NPU 设备号合入社区或者后续Pytorch版本`_has_compatible_shallow_copy_type`注册方式发生变动,该warning会被解决。
待NPU 设备号合入社区或者后续PyTorch版本`_has_compatible_shallow_copy_type`注册方式发生变动,该warning会被解决。
![输入图片说明](https://images.gitee.com/uploads/images/2022/0701/153621_2b5080c4_7902902.png)
@@ -493,9 +671,53 @@ warning如下图所示,由Tensor.set_data浅拷贝操作触发。主要原因
验证torch_npu的引入,请切换至其他目录进行,在编译目录执行会提示如下错误。
<img src="figures/FAQ torch_npu.png" style="zoom:150%;" />
## 在执行import torch_npu时出现ModuleNotFooundError: NO module named '_lzma'报错问题
在python命令行下,执行import torch_npu测试时,出现ModuleNotFooundError: NO module named '_lzma'问题,可能由于Python环境失效,重装Python即可。<img src="figures/QA.png" />
## 编译过程中出现XNNPACK相关的Make Error报错
编译原生pytorch时,未配置相关环境变量,导致编译不成功。
![](figures/QA1.png)
1. 执行命令设置环境变量
```
export USE_XNNPACK=0
```
2. 执行命令清除当前编译内容
```
make clean
```
3. 重新编译
## 编译时出现Breakpad error: field 'regs' has incomplete type 'google_breakpad::user_regs_struct'报错
编译原生pytorch时,未配置相关环境变量,导致编译不成功。
1. 执行命令配置环境变量
```
export BUILD_BREAKPAD=0
```
2. 执行命令清除当前编译内容
```
make clean
```
3. 重新编译
## 多卡训练初始化阶段卡顿至超时
init_process_group 函数中使用了IPV6地址,例如::1(注意localhost 可能指向IPv6的地址),使用IPv4可以避免这个问题
# 版本说明
版本说明请参阅[ReleseNote](docs/zh/RELEASENOTE)

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,4 +1,18 @@
# FrameworkPTAdapter 3.0.RC2 版本说明书
# FrameworkPTAdapter 3.0.0 版本说明书
- [FrameworkPTAdapter 3.0.0](#FrameworkPTAdapter-3-0-0md)
- [用户须知](#用户须知md)
- [新增特性](#新增特性md)
- [特性修改](#特性修改md)
- [已修复问题](#已修复问题md)
- [已知问题](#已知问题md)
- [兼容性](#兼容性md)
- [FrameworkPTAdapter 3.0.RC3](#FrameworkPTAdapter-3-0-RC3md)
- [用户须知](#用户须知md)
- [新增特性](#新增特性md)
- [特性修改](#特性修改md)
- [已修复问题](#已修复问题md)
- [已知问题](#已知问题md)
- [兼容性](#兼容性md)
- [FrameworkPTAdapter 3.0.RC2](#FrameworkPTAdapter-3-0-RC2md)
- [用户须知](#用户须知md)
- [新增特性](#新增特性md)
@@ -35,6 +49,174 @@
- [已知问题](#已知问题-4md)
- [兼容性](#兼容性-5md)
<h2 id="FrameworkPTAdapter-3-0-0md">FrameworkPTAdapter 3.0.0</h2>
<h3 id="用户须知md">用户须知</h3>
本框架基于Facebook主导的开源PyTorch进行修改,延续原生的PyTorch特性,使用NPU进行动态图训练;以算子粒度进行模型适配,代码重用性好,支持现有的网络只修改设备类型或数据类型,即可迁移到NPU上使用。
PyTorch1.8.1版本开始采用插件化适配方式,与原生PyTorch框架实现彻底解耦,功能、性能与PyTorch1.5.0基本保持一致,对后端算子适配提供较好开发体验。PyTorch 1.11.0当前为beta版本,建议优先使用PyTorch 1.8.1版本。
<h3 id="新增特性md">新增特性</h3>
**表 1** PyTorch支持的版本特性列表
<a name="t76c34275cbb74753970f7c5a9eb594fa"></a>
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="25.590000000000003%" 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="15.52%" 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="58.89%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>说明</p>
</th>
</tr>
</thead>
<tbody><tr id="row91681125173610"><td class="cellrowborder" valign="top" width="25.590000000000003%" headers="mcps1.2.4.1.1 "><p id="p1712174492611"><a name="p1712174492611"></a><a name="p1712174492611"></a>适配NPU的PyTorch1.5.0特性</p>
</td>
<td class="cellrowborder" valign="top" width="15.52%" headers="mcps1.2.4.1.2 "><p id="p2168172519364"><a name="p2168172519364"></a><a name="p2168172519364"></a>框架基础功能</p>
</td>
<td class="cellrowborder" valign="top" width="58.89%" headers="mcps1.2.4.1.3 "><p id="p1416815259367"><a name="p1416815259367"></a><a name="p1416815259367"></a>适配CANN算子IR变更。</p>
</td>
</tr>
<tr id="row2620183971614"><td class="cellrowborder" rowspan="3" valign="top" width="25.590000000000003%" headers="mcps1.2.4.1.1 "><p id="p0819102247"><a name="p0819102247"></a><a name="p0819102247"></a>适配NPU的PyTorch1.8.1特性</p>
<p id="p15488161812213"><a name="p15488161812213"></a><a name="p15488161812213"></a></p>
</td>
<td class="cellrowborder" valign="top" width="15.52%" headers="mcps1.2.4.1.2 "><p id="p76365489137"><a name="p76365489137"></a><a name="p76365489137"></a>框架基础功能</p>
</td>
<td class="cellrowborder" valign="top" width="58.89%" headers="mcps1.2.4.1.3 "><p id="p363616485131"><a name="p363616485131"></a><a name="p363616485131"></a>支持NPU Tensor类型,修复少量BUG</p>
</td>
</tr>
<tr id="row945906124515"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1077934311314"><a name="p1077934311314"></a><a name="p1077934311314"></a>序列化存取</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p977954315133"><a name="p977954315133"></a><a name="p977954315133"></a>支持NPU Tensor直接序列化存取,完善torch.save/load接口能力</p>
</td>
</tr>
<tr id="row13545374516"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p44561110214"><a name="p44561110214"></a><a name="p44561110214"></a>精度对比工具</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p412459182110"><a name="p412459182110"></a><a name="p412459182110"></a>支持溢出检测,优化数据dump性能</p>
</td>
</tr>
<tr id="row3722227133312"><td class="cellrowborder" rowspan="3" valign="top" width="25.590000000000003%" headers="mcps1.2.4.1.1 "><p id="p107221327153315"><a name="p107221327153315"></a><a name="p107221327153315"></a>适配NPU的PyTorch1.11.0特性</p>
</td>
<td class="cellrowborder" valign="top" width="15.52%" headers="mcps1.2.4.1.2 "><p id="p153563917719"><a name="p153563917719"></a><a name="p153563917719"></a>框架基础功能</p>
</td>
<td class="cellrowborder" valign="top" width="58.89%" headers="mcps1.2.4.1.3 "><p id="p272242719336"><a name="p272242719336"></a><a name="p272242719336"></a>支持NPU Tensor类型,修复少量BUG</p>
</td>
</tr>
<tr id="row6631141014305"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1416445591310"><a name="p1416445591310"></a><a name="p1416445591310"></a>序列化存取</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11164185561312"><a name="p11164185561312"></a><a name="p11164185561312"></a>支持NPU Tensor直接序列化存取,完善torch.save/load接口能力</p>
</td>
</tr>
<tr id="row270811563411"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p121645556134"><a name="p121645556134"></a><a name="p121645556134"></a>精度对比工具</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1716425591313"><a name="p1716425591313"></a><a name="p1716425591313"></a>支持溢出检测,优化数据dump性能</p>
</td>
</tr>
</tbody>
</table>
<h3 id="特性修改md">特性修改</h3>
不涉及
<h3 id="已修复问题md">已修复问题</h3>
不涉及
<h3 id="已知问题md">已知问题</h3>
<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>
</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>
<h3 id="兼容性md">兼容性</h3>
A800-9010:CentOS 7.6/Ubuntu 18.04, 2.04/BC-Linux 7.6/Debian 9.9/Debian 10/OpenEuler 20.03 LTS
A800-9000:CentOS 7.6/Ubuntu 18.04, 2.04/Euler 2.8, 2.10/Kylin v10/BC-Linux 7.6/OpenEuler 20.03 LTS/UOS 20 1020e
<h2 id="FrameworkPTAdapter-3-0-RC3md">FrameworkPTAdapter 3.0.RC3</h2>
<h3 id="用户须知md">用户须知</h3>
本框架基于Facebook主导的开源PyTorch进行修改,延续原生的PyTorch特性,使用NPU进行动态图训练;以算子粒度进行模型适配,代码重用性好,支持现有的网络只修改设备类型或数据类型,即可迁移到NPU上使用。
PyTorch1.8.1版本开始采用插件化适配方式,与原生PyTorch框架实现彻底解耦,功能、性能与PyTorch1.5.0基本保持一致,对后端算子适配提供较好开发体验。
<h3 id="新增特性md">新增特性</h3>
**表 1** PyTorch支持的版本特性列表
| 一级特性 | 二级特性 | 说明 |
| -------------------------- | -------------------------------- | ---------------------------------------------- |
| 适配NPU的PyTorch1.5.0特性 | 框架基础功能 | 适配CANN算子IR变更。 |
| 适配NPU的PyTorch1.8.1特性 | 精度对比工具 | 支持NPU与CPU精度对比工具。 |
| profiling | 支持自定义算子profiling。 | |
| API满足度提升 | 新增部分API适配(详见API清单)。 | |
| 适配NPU的PyTorch1.11.0特性 | 框架基础功能 | 支持模型训练功能,适配算子API(详见API清单)。 |
| 混合精度 | 支持apex混合精度训练。 | |
| 分布式 | 支持DDP分布式训练功能。 | |
| profiling | 支持E2E profiling功能。 | |
<h3 id="特性修改md">特性修改</h3>
不涉及
<h3 id="已修复问题md">已修复问题</h3>
不涉及
<h3 id="已知问题md">已知问题</h3>
| 已知问题 | 问题描述 |
| --------------------------------------------- | ------------------------------------------------------------ |
| 数据类型支持 | NPU不支持float16类型的inf/nan数据输入输出。 |
| 数据Format | 出现4D以上的format时不能降维。 |
| 集合通信约束 | 要求一次训练任务中不同device上执行的图相同。 |
| 当前只支持1/2/4/8P粒度的分配。 | |
| 只支持int8,int32,float16和float32数据类型。 | |
| Apex功能支持 | Apex当前版本的实现方式主要为python实现,不支持APEX中的自定义优化CUDA Kernel。 |
<h3 id="兼容性md">兼容性</h3>
A800-9010:CentOS 7.6/Ubuntu 18.04, 2.04/BC-Linux 7.6/Debian 9.9/Debian 10/OpenEuler 20.03 LTS
A800-9000:CentOS 7.6/Ubuntu 18.04, 2.04/Euler 2.8, 2.10/Kylin v10/BC-Linux 7.6/OpenEuler 20.03 LTS/UOS 20 1020e
<h2 id="FrameworkPTAdapter-3-0-RC2md">FrameworkPTAdapter 3.0.RC2</h2>

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 394 B

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

@@ -1,918 +0,0 @@
# Multi-server Multi-device Training Adaptation Guide for PyTorch Models
- [Overview](#overview)
- [Training Workflow](#training-workflow)
- [Quick Start](#quick-start)
- [Overview](#overview-1)
- [Setting Up the Environment](#setting-up-the-environment)
- [Preparing a Model](#preparing-a-model)
- [Modifying the Model](#modifying-the-model)
- [Starting the Training](#starting-the-training)
- [Multi-server Multi-device Training](#multi-server-multi-device-training)
- [Common Concepts and Parameters](#common-concepts-and-parameters)
- [Multi-server Multi-device Training Process](#multi-server-multi-device-training-process)
- [Setting Up the Environment](#setting-up-the-environment-1)
- [Preparing a Model](#preparing-a-model-1)
- [Modifying the Model](#modifying-the-model-1)
- [Start the Training](#start-the-training)
- [Appendix](#appendix)
# 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 setup, model preparation, model modification, and training startup.
1. Environment Setup
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.
## Setting Up 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
### Setting Up 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:
```
xxx.xxx.xxx.111 ubuntu
```
In the preceding content, **xxx.xxx.xxx.111** 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 **xxx.xxx.xxx.111**.):
```
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@xxx.xxx.xxx.111:~/.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@xxx.xxx.xxx.222** command to log in to the server whose IP address is xxx.xxx.xxx.222 from the first server whose IP address is xxx.xxx.xxx.111 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 xxx.xxx.xxx.222 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
export LD_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
```
File diff suppressed because it is too large Load Diff
@@ -1,475 +0,0 @@
# PyTorch Installation Guide
- [Overview](#overviewa-nameoverviewa)
- [System Dependencies](#system-dependenciesa-namesystem-dependenciesa)
- [Ascend Auxiliary Software](#ascend-auxiliary-softwarea-nameascend-auxiliary-softwarea)
- [Installation Methods](#installation-methodsa-nameinstallation-methodsa)
- [Running](#runninga-namerunninga)
- [(Optional) Installing the Mixed Precision Module](#optional-installing-the-mixed-precision-modulea-nameoptional-installing-the-mixed-precision-modulea)
- [FAQs](#faqsa-namefaqsa)
- [Version Descriptio](#version-descriptiona-nameversion-descriptiona)
# Overview<a name="Overview"></a>
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. When setting up the environments for PyTorch model development and operating, developers can manually compile related modules on servers.
## Prerequisites
- The development or operating environment of CANN has been installed. For details, see the *CANN Software Installation Guide*.
- Python 3.7.5, 3.8, and 3.9 are supported.
# System Dependencies<a name="System-Dependencies"></a>
## CentOS & EulerOS
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git dos2unix
yum install -y gcc==7.3.0 cmake==3.12.0
## Ubuntu
apt-get install -y patch 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 dos2unix libopenblas-dev git dos2unix
apt-get install -y gcc==7.3.0 cmake==3.12.0
>![](public_sys-resources/icon-note.gif) **NOTE:**
>If an error occurs during the installation of the GCC and CMake dependency commands, use the source code for installation. For details, see the FAQ.
# Ascend Auxiliary Software<a name="Ascend-Auxiliary-Software"></a>
| AscendPyTorch Version| CANN Version| Supported PyTorch Version| Gitee Branch|
| :------------ | :----------- | :----------- | ------------- |
| 2.0.2 | CANN 5.0.2 | 1.5.0.post2 | 2.0.2.tr5 |
| 2.0.3 | CANN 5.0.3 | 1.5.0.post3 | 2.0.3.tr5 |
| 2.0.4 | CANN 5.0.4 | 1.5.0.post4 | 2.0.4.tr5 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
# Installation Methods<a name="Installation-Methods"></a>
## Install the PyTorch environment dependencies.
If you install dependencies as a non-root user, add **--user** at the end of each command in this step, for example, **pip3 install pyyaml --user**.
```sh
pip3 install pyyaml
pip3 install wheel
```
## Compile and install the PyTorch and Ascend plugin.
Install the official torch package, and then compile and install the plugin.
```sh
#x86_64
pip3 install torch==1.8.1+cpu # If an error is reported when you run the pip command to install PyTorch of the CPU version, manually download the .whl package from https://download.pytorch.org/whl/torch.
#AArch64
#The community does not provide the CPU installation package of the ARM architecture. For details, see the first FAQ to compile and install PyTorch using the source code.
```
Compile and generate the binary installation package of the PyTorch plugin.
```
# Download code of the corresponding branch and go to the root directory of the plugin.
git clone -b v1.8.1-3.0.rc2 https://gitee.com/ascend/pytorch.git
cd pytorch
# Specify the Python version packaging mode:
bash ci/build.sh --python=3.7
# or
bash ci/build.sh --python=3.8
#or
bash ci/build.sh --python=3.9
```
Install the **torch_npu** package generated in the **pytorch/dist** directory. *{arch}* indicates the architecture name.
```
pip3 install --upgrade dist/torch_npu-1.8.1rc2-cp37-cp37m-linux_{arch}.whl
```
Download TorchVision.
```
pip3 install torchvision==0.9.1
```
# Running<a name="Running"></a>
## Execute environment variables.
Run the script for setting environment variables in the root directory of the current repository.
```
source env.sh
```
## Customize environment variables.
The following are optional environment variables that may affect running models:
```
export COMBINED_ENABLE=1 # (Optional) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to 1. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency.
export ACL_DUMP_DATA=1 # (Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to 1.
```
**Table 1** Description of environment variables
<a name="zh-cn_topic_0000001152616261_table42017516135"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001152616261_p51981251161315"><a name="zh-cn_topic_0000001152616261_p51981251161315"></a><a name="zh-cn_topic_0000001152616261_p51981251161315"></a>Environment Variable</p>
</th>
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001152616261_p9198135114133"><a name="zh-cn_topic_0000001152616261_p9198135114133"></a><a name="zh-cn_topic_0000001152616261_p9198135114133"></a>Description</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) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to 1. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency. However, the host delivery performance may deteriorate.</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 1.</p>
</td>
</tr>
</tbody>
</table>
## Run the unit test script.
Verify the running. The output is **OK**.
```shell
cd test/test_network_ops/
python3 test_div.py
```
# (Optional) Installing the Mixed Precision Module<a name="(Optional) Installing the Mixed Precision Module"></a>
AscendPyTorch 1.8.1 integrates the AMP module and can be used for training with mixed precision. The differences between the AMP module and the Apex module are as follows. You can select a desired module. For details about how to compile and install the Apex module, see the related [**README.en**](https://gitee.com/ascend/apex) file.
- AMP
- Dynamic loss scale: The loss scale value is dynamically calculated to determine whether overflow occurs.
- Tensor fusion is not supported.
- Apex
- O1 configuration mode: Conv and Matmul use the float16 precision for computing, and Softmax and BN use float32.
- O2 configuration mode: BN uses the float32 precision for computing, and others use float16.
- Static loss scale: Parameters are statically set to ensure the convergence of training with mixed precision.
- Dynamic loss scale: The loss scale value is dynamically calculated to determine whether overflow occurs.
# FAQs<a name="FAQs"></a>
## When the CPU architecture is ARM, PyTorch 1.8.1 cannot be installed using the PIP3 command because the community does not provide the torch package for the ARM CPU architecture. In this case, use the source code to compile and install PyTorch 1.8.1.
Download the PyTorch 1.8.1 source package.
```
git clone -b v1.8.1 https://github.com/pytorch/pytorch.git --depth=1 pytorch_v1.8.1
```
Access the source package to obtain the passive dependency code.
```
cd pytorch_v1.8.1
git submodule sync
git submodule update --init --recursive
```
Compile and install PyTorch 1.8.1.
```
python3 setup.py install
```
## When PIP is set to the Huawei source, a Python environment error occurs after the typing dependency in the **requirements.txt** file is installed.
When PIP is set to the Huawei source, open the **requirements.txt** file, delete the typing dependency, and then run the following command:
```
pip3 install -r requirments.txt
```
## 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 # {arch} is the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
User state:
```
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64 # {arch} is the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
## During CMake installation through the CLI, an error is reported indicating that the package cannot be found. During CMake compilation, another error is reported indicating that the version is too early. In this cause, you can use the installation script or source code to compile and install CMake.
Method 1: Download the installation script and install CMake. (For details, see the CMake official website.)
​ x86_64 environment: cmake-3.12.0-Linux-x86_64.sh
​ AArch64 environment: cmake-3.12.0-Linux-aarch64.sh
1. Run the following command:
```
./cmake-3.12.0-Linux-{arch}.sh # {arch} indicates the architecture name.
```
2. Set the soft link.
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
3. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
Method 2: Use the source code to compile and install.
1. Obtain the CMake software package.
```
wget https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz --no-check-certificate
```
2. Decompress the package and go to the software package directory.
```
tar -xf cmake-3.12.0.tar.gz
cd cmake-3.12.0/
```
3. Run the configuration, compilation, 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. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
## During GCC installation through the CLI, an error is reported indicating that the package cannot be found. During GCC compilation, another error is reported.
When downloading GCC from some sources, you may be prompted by an error message indicating that the package cannot be found. In this case, use the source code to compile and install GCC.
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. Compile 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 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 verification fails, check whether there are duplicate dependency packages in the folder. If yes, delete duplicate ones.
3. <a name="zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310"></a>Run the configuration, compilation, 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. You can set the parameters as required.
make install
```
>![](public_sys-resources/icon-notice.gif) **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**.
4. Change the soft links.
```
ln -s ${install_path}/bin/gcc /usr/bin/gcc
ln -s ${install_path}/bin/g++ /usr/bin/g++
ln -s ${install_path}/bin/c++ /usr/bin/c++
```
5. Configure environment variables.
Training must be performed in the compilation environment with GCC upgraded. If you want to run training, 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](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310). In this example, the GCC 7.3.0 installation path is **/usr/local/linux_gcc7.3.0/**.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Skip this step if you do not need to use the compilation environment with GCC upgraded.
If the PyTorch compilation fails, check whether the soft link library is correct.
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
```
## No device is mounted to the container.
An NPU-related error is reported when a script is run in the container. The **device** parameter is not set before container instance startup. As a result, the instance cannot be started.
![](figures/FAQ.png)
Run the following command to restart the container:
```sh
docker run -it --ipc=host \
--device=/dev/davinciX \
--device=/dev/davinci_manager \
--device=/dev/devmm_svm \
--device=/dev/hisi_hdc \
-v /usr/local/Ascend/driver \
-v /usr/local/dcmi \
-v /usr/local/bin/npu-smi \
${image name}:{tag} \
/bin/bash
```
Parameter description:
**/dev/davinci*X***: NPU device. *X* is the physical ID of the chip, for example, **davinci0**.
**/dev/davinci_manager**: management device
**/dev/devmm_svm**: management device
**/dev/hisi_hdc**: management device
**/usr/local/Ascend/driver**: driver directory
**/usr/local/dcmi**: DCMI directory
**/usr/local/bin/npu-smi**: npu-smi tool
**$*{image name}:{tag}***: image name and version
## An error is displayed during installation of -torch--whl-, indicating that -torch-1-5-0xxxx- and -torchvision- versions do not match.
During 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.
![](https://gitee.com/ascend/pytorch/raw/v1.8.1-3.0.rc2/figures/zh-cn_image_0000001190081735.png)
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.
This problem does not affect the actual result, and no action is required.
## When you run **import torch_npu**, if "_has_compatible_shallow_copy_type" is output, a warning about a repeated registration error is displayed.
The warning is triggered by the shallow copy operation of **Tensor.set_data**, as shown in the following figure. The main cause is that after the PyTorch plugin is decoupled, `_has_compatible_shallow_copy_type` cannot detect shallow copy of NPU tensors. You need to register `_has_compatible_shallow_copy_type` again.
This error can be ignored because it does not affect the model accuracy and performance.
It will be resolved after the NPU's device ID is incorporated into the community or the `_has_compatible_shallow_copy_type` registration mode is changed in a later PyTorch version.
![Input Image Description](https://images.gitee.com/uploads/images/2022/0701/153621_2b5080c4_7902902.png)
## An error is reported when torch_npu is referenced with Python commands in the compilation directory.
To verify the torch_npu reference, switch to another directory. If you perform the verification in the compilation directory, the following error message is displayed:
<img src="figures/FAQ torch_npu.png" style="zoom:150%;" />
# Version Description<a name='Version Description'></a>
For details, see [Release Notes](https://gitee.com/ascend/pytorch/tree/master/docs/en/RELEASENOTE).
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

@@ -1,600 +0,0 @@
# 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 310P 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>
![](figures/online-inference-process.png "online-inference-process")
<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>
>![](public_sys-resources/icon-note.gif) **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_npu
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
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.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](https://gitee.com/ascend/ModelZoo-PyTorch/blob/master/PyTorch/built-in/cv/classification/ResNet50_for_PyTorch/env_npu.sh) and then run the following command:
```
python3 resnet50_infer_for_pytorch.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.
```
>![](public_sys-resources/icon-note.gif) **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>
>![](public_sys-resources/icon-note.gif) **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 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
```
>![](public_sys-resources/icon-notice.gif) **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/**.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Skip this step if you do not the compilation environment with GCC upgraded.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Some files were not shown because too many files have changed in this diff Show More