Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
964643ee
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
964643ee
编写于
12月 07, 2022
作者:
A
Aganlengzi
提交者:
GitHub
12月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support custom npu (#7461)
上级
cc15a9b6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
11 deletion
+18
-11
ppdet/engine/trainer.py
ppdet/engine/trainer.py
+12
-6
ppdet/utils/check.py
ppdet/utils/check.py
+6
-5
未找到文件。
ppdet/engine/trainer.py
浏览文件 @
964643ee
...
...
@@ -421,8 +421,10 @@ class Trainer(object):
model
=
self
.
model
if
self
.
cfg
.
get
(
'to_static'
,
False
):
model
=
apply_to_static
(
self
.
cfg
,
model
)
sync_bn
=
(
getattr
(
self
.
cfg
,
'norm_type'
,
None
)
==
'sync_bn'
and
(
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_mlu
)
and
self
.
_nranks
>
1
)
sync_bn
=
(
getattr
(
self
.
cfg
,
'norm_type'
,
None
)
==
'sync_bn'
and
(
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_npu
or
self
.
cfg
.
use_mlu
)
and
self
.
_nranks
>
1
)
if
sync_bn
:
model
=
paddle
.
nn
.
SyncBatchNorm
.
convert_sync_batchnorm
(
model
)
...
...
@@ -484,7 +486,8 @@ class Trainer(object):
DataParallel
)
and
use_fused_allreduce_gradients
:
with
model
.
no_sync
():
with
paddle
.
amp
.
auto_cast
(
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_mlu
,
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_npu
or
self
.
cfg
.
use_mlu
,
custom_white_list
=
self
.
custom_white_list
,
custom_black_list
=
self
.
custom_black_list
,
level
=
self
.
amp_level
):
...
...
@@ -498,7 +501,8 @@ class Trainer(object):
list
(
model
.
parameters
()),
None
)
else
:
with
paddle
.
amp
.
auto_cast
(
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_mlu
,
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_npu
or
self
.
cfg
.
use_mlu
,
custom_white_list
=
self
.
custom_white_list
,
custom_black_list
=
self
.
custom_black_list
,
level
=
self
.
amp_level
):
...
...
@@ -612,7 +616,8 @@ class Trainer(object):
# forward
if
self
.
use_amp
:
with
paddle
.
amp
.
auto_cast
(
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_mlu
,
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_npu
or
self
.
cfg
.
use_mlu
,
custom_white_list
=
self
.
custom_white_list
,
custom_black_list
=
self
.
custom_black_list
,
level
=
self
.
amp_level
):
...
...
@@ -679,7 +684,8 @@ class Trainer(object):
# forward
if
self
.
use_amp
:
with
paddle
.
amp
.
auto_cast
(
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_mlu
,
enable
=
self
.
cfg
.
use_gpu
or
self
.
cfg
.
use_npu
or
self
.
cfg
.
use_mlu
,
custom_white_list
=
self
.
custom_white_list
,
custom_black_list
=
self
.
custom_black_list
,
level
=
self
.
amp_level
):
...
...
ppdet/utils/check.py
浏览文件 @
964643ee
...
...
@@ -53,16 +53,17 @@ def check_mlu(use_mlu):
def
check_npu
(
use_npu
):
"""
Log error and exit when set use_npu=true in paddlepaddle
cpu/gpu/xpu version
.
version without paddle-custom-npu installed
.
"""
err
=
"Config use_npu cannot be set as true while you are "
\
"using paddlepaddle cpu/gpu/xpu version !
\n
Please try:
\n
"
\
"
\t
1. Install paddlepaddle-npu to run model on NPU
\n
"
\
"using paddlepaddle version without paddle-custom-npu "
\
"installed!
\n
Please try:
\n
"
\
"
\t
1. Install paddle-custom-npu to run model on NPU
\n
"
\
"
\t
2. Set use_npu as false in config file to run "
\
"model on
CPU/GPU/XPU
"
"model on
other devices supported.
"
try
:
if
use_npu
and
not
paddle
.
is_compiled_with_npu
():
if
use_npu
and
not
'npu'
in
paddle
.
device
.
get_all_custom_device_type
():
logger
.
error
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录