Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
65412088
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
65412088
编写于
12月 15, 2020
作者:
Q
QingshuChen
提交者:
GitHub
12月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support mask_rcnn for kunlun (#1890)
* support mask_rcnn for kunlun * minor
上级
2486a941
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
5 deletion
+61
-5
ppdet/utils/check.py
ppdet/utils/check.py
+20
-0
tools/eval.py
tools/eval.py
+16
-2
tools/train.py
tools/train.py
+25
-3
未找到文件。
ppdet/utils/check.py
浏览文件 @
65412088
...
...
@@ -28,12 +28,32 @@ logger = logging.getLogger(__name__)
__all__
=
[
'check_gpu'
,
'check_xpu'
,
'check_version'
,
'check_config'
,
'check_py_func'
,
]
def
check_xpu
(
use_xpu
):
"""
Log error and exit when set use_xpu=true in paddlepaddle
cpu/gpu version.
"""
err
=
"Config use_xpu cannot be set as true while you are "
\
"using paddlepaddle cpu/gpu version !
\n
Please try:
\n
"
\
"
\t
1. Install paddlepaddle-xpu to run model on XPU
\n
"
\
"
\t
2. Set use_xpu as false in config file to run "
\
"model on CPU/GPU"
try
:
if
use_xpu
and
not
fluid
.
is_compiled_with_xpu
():
logger
.
error
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
pass
def
check_gpu
(
use_gpu
):
"""
Log error and exit when set use_gpu=true in paddlepaddle
...
...
tools/eval.py
浏览文件 @
65412088
...
...
@@ -27,7 +27,7 @@ import paddle.fluid as fluid
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.check
import
check_gpu
,
check_
xpu
,
check_
version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
...
...
@@ -49,15 +49,27 @@ def main():
check_config
(
cfg
)
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
use_xpu
=
False
if
hasattr
(
cfg
,
'use_xpu'
):
check_xpu
(
cfg
.
use_xpu
)
use_xpu
=
cfg
.
use_xpu
# check if paddlepaddle version is satisfied
check_version
()
assert
not
(
use_xpu
and
cfg
.
use_gpu
),
\
'Can not run on both XPU and GPU'
main_arch
=
cfg
.
architecture
multi_scale_test
=
getattr
(
cfg
,
'MultiScaleTEST'
,
None
)
# define executor
place
=
fluid
.
CUDAPlace
(
0
)
if
cfg
.
use_gpu
else
fluid
.
CPUPlace
()
if
cfg
.
use_gpu
:
place
=
fluid
.
CUDAPlace
(
0
)
elif
use_xpu
:
place
=
fluid
.
XPUPlace
(
0
)
else
:
place
=
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
# build program
...
...
@@ -91,6 +103,8 @@ def main():
return
compile_program
=
fluid
.
CompiledProgram
(
eval_prog
).
with_data_parallel
()
if
use_xpu
:
compile_program
=
eval_prog
assert
cfg
.
metric
!=
'OID'
,
"eval process of OID dataset
\
is not supported."
...
...
tools/train.py
浏览文件 @
65412088
...
...
@@ -43,7 +43,7 @@ from ppdet.utils import dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.check
import
check_gpu
,
check_
xpu
,
check_
version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
logging
...
...
@@ -73,9 +73,16 @@ def main():
check_config
(
cfg
)
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
use_xpu
=
False
if
hasattr
(
cfg
,
'use_xpu'
):
check_xpu
(
cfg
.
use_xpu
)
use_xpu
=
cfg
.
use_xpu
# check if paddlepaddle version is satisfied
check_version
()
assert
not
(
use_xpu
and
cfg
.
use_gpu
),
\
'Can not run on both XPU and GPU'
save_only
=
getattr
(
cfg
,
'save_prediction_only'
,
False
)
if
save_only
:
raise
NotImplementedError
(
'The config file only support prediction,'
...
...
@@ -84,14 +91,25 @@ def main():
if
cfg
.
use_gpu
:
devices_num
=
fluid
.
core
.
get_cuda_device_count
()
elif
use_xpu
:
# ToDo(qingshu): XPU only support single card now
devices_num
=
1
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
if
'FLAGS_selected_gpus'
in
env
:
if
cfg
.
use_gpu
and
'FLAGS_selected_gpus'
in
env
:
device_id
=
int
(
env
[
'FLAGS_selected_gpus'
])
elif
use_xpu
and
'FLAGS_selected_xpus'
in
env
:
device_id
=
int
(
env
[
'FLAGS_selected_xpus'
])
else
:
device_id
=
0
place
=
fluid
.
CUDAPlace
(
device_id
)
if
cfg
.
use_gpu
else
fluid
.
CPUPlace
()
if
cfg
.
use_gpu
:
place
=
fluid
.
CUDAPlace
(
device_id
)
elif
use_xpu
:
place
=
fluid
.
XPUPlace
(
device_id
)
else
:
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
lr_builder
=
create
(
'LearningRate'
)
...
...
@@ -184,9 +202,13 @@ def main():
loss_name
=
loss
.
name
,
build_strategy
=
build_strategy
,
exec_strategy
=
exec_strategy
)
if
use_xpu
:
compiled_train_prog
=
train_prog
if
FLAGS
.
eval
:
compiled_eval_prog
=
fluid
.
CompiledProgram
(
eval_prog
)
if
use_xpu
:
compiled_eval_prog
=
eval_prog
fuse_bn
=
getattr
(
model
.
backbone
,
'norm_type'
,
None
)
==
'affine_channel'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录