Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
35e710c5
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看板
未验证
提交
35e710c5
编写于
2月 09, 2022
作者:
H
houj04
提交者:
GitHub
2月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for xpu. (#5176)
上级
0a3d768c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
4 deletion
+51
-4
ppdet/utils/check.py
ppdet/utils/check.py
+22
-1
static/tools/infer.py
static/tools/infer.py
+7
-1
tools/eval.py
tools/eval.py
+8
-1
tools/infer.py
tools/infer.py
+8
-1
tools/train.py
tools/train.py
+6
-0
未找到文件。
ppdet/utils/check.py
浏览文件 @
35e710c5
...
@@ -25,7 +25,9 @@ import paddle.version as fluid_version
...
@@ -25,7 +25,9 @@ import paddle.version as fluid_version
from
.logger
import
setup_logger
from
.logger
import
setup_logger
logger
=
setup_logger
(
__name__
)
logger
=
setup_logger
(
__name__
)
__all__
=
[
'check_gpu'
,
'check_npu'
,
'check_version'
,
'check_config'
]
__all__
=
[
'check_gpu'
,
'check_npu'
,
'check_xpu'
,
'check_version'
,
'check_config'
]
def
check_npu
(
use_npu
):
def
check_npu
(
use_npu
):
...
@@ -47,6 +49,25 @@ def check_npu(use_npu):
...
@@ -47,6 +49,25 @@ def check_npu(use_npu):
pass
pass
def
check_xpu
(
use_xpu
):
"""
Log error and exit when set use_xpu=true in paddlepaddle
cpu/gpu/npu version.
"""
err
=
"Config use_xpu cannot be set as true while you are "
\
"using paddlepaddle cpu/gpu/npu 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/NPU"
try
:
if
use_xpu
and
not
paddle
.
is_compiled_with_xpu
():
logger
.
error
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
pass
def
check_gpu
(
use_gpu
):
def
check_gpu
(
use_gpu
):
"""
"""
Log error and exit when set use_gpu=true in paddlepaddle
Log error and exit when set use_gpu=true in paddlepaddle
...
...
static/tools/infer.py
浏览文件 @
35e710c5
...
@@ -41,7 +41,7 @@ try:
...
@@ -41,7 +41,7 @@ try:
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_
xpu
,
check_
version
,
check_config
,
enable_static_mode
from
ppdet.utils.visualizer
import
visualize_results
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
import
ppdet.utils.checkpoint
as
checkpoint
...
@@ -113,6 +113,10 @@ def main():
...
@@ -113,6 +113,10 @@ def main():
if
'use_npu'
not
in
cfg
:
if
'use_npu'
not
in
cfg
:
cfg
.
use_npu
=
False
cfg
.
use_npu
=
False
check_npu
(
cfg
.
use_npu
)
check_npu
(
cfg
.
use_npu
)
# disable xpu in config by default and check use_xpu
if
'use_xpu'
not
in
cfg
:
cfg
.
use_xpu
=
False
check_xpu
(
cfg
.
use_xpu
)
# check if paddlepaddle version is satisfied
# check if paddlepaddle version is satisfied
check_version
()
check_version
()
...
@@ -127,6 +131,8 @@ def main():
...
@@ -127,6 +131,8 @@ def main():
place
=
fluid
.
CUDAPlace
(
0
)
place
=
fluid
.
CUDAPlace
(
0
)
elif
cfg
.
use_npu
:
elif
cfg
.
use_npu
:
place
=
fluid
.
NPUPlace
(
0
)
place
=
fluid
.
NPUPlace
(
0
)
elif
cfg
.
use_xpu
:
place
=
fluid
.
XPUPlace
(
0
)
else
:
else
:
place
=
fluid
.
CPUPlace
()
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
=
fluid
.
Executor
(
place
)
...
...
tools/eval.py
浏览文件 @
35e710c5
...
@@ -30,7 +30,7 @@ warnings.filterwarnings('ignore')
...
@@ -30,7 +30,7 @@ warnings.filterwarnings('ignore')
import
paddle
import
paddle
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_version
,
check_config
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_
xpu
,
check_
version
,
check_config
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.engine
import
Trainer
,
init_parallel_env
from
ppdet.engine
import
Trainer
,
init_parallel_env
from
ppdet.metrics.coco_utils
import
json_eval_results
from
ppdet.metrics.coco_utils
import
json_eval_results
...
@@ -120,10 +120,16 @@ def main():
...
@@ -120,10 +120,16 @@ def main():
if
'use_npu'
not
in
cfg
:
if
'use_npu'
not
in
cfg
:
cfg
.
use_npu
=
False
cfg
.
use_npu
=
False
# disable xpu in config by default
if
'use_xpu'
not
in
cfg
:
cfg
.
use_xpu
=
False
if
cfg
.
use_gpu
:
if
cfg
.
use_gpu
:
place
=
paddle
.
set_device
(
'gpu'
)
place
=
paddle
.
set_device
(
'gpu'
)
elif
cfg
.
use_npu
:
elif
cfg
.
use_npu
:
place
=
paddle
.
set_device
(
'npu'
)
place
=
paddle
.
set_device
(
'npu'
)
elif
cfg
.
use_xpu
:
place
=
paddle
.
set_device
(
'xpu'
)
else
:
else
:
place
=
paddle
.
set_device
(
'cpu'
)
place
=
paddle
.
set_device
(
'cpu'
)
...
@@ -136,6 +142,7 @@ def main():
...
@@ -136,6 +142,7 @@ def main():
check_config
(
cfg
)
check_config
(
cfg
)
check_gpu
(
cfg
.
use_gpu
)
check_gpu
(
cfg
.
use_gpu
)
check_npu
(
cfg
.
use_npu
)
check_npu
(
cfg
.
use_npu
)
check_xpu
(
cfg
.
use_xpu
)
check_version
()
check_version
()
run
(
FLAGS
,
cfg
)
run
(
FLAGS
,
cfg
)
...
...
tools/infer.py
浏览文件 @
35e710c5
...
@@ -31,7 +31,7 @@ import glob
...
@@ -31,7 +31,7 @@ import glob
import
paddle
import
paddle
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.engine
import
Trainer
from
ppdet.engine
import
Trainer
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_version
,
check_config
from
ppdet.utils.check
import
check_gpu
,
check_npu
,
check_
xpu
,
check_
version
,
check_config
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.slim
import
build_slim_model
from
ppdet.slim
import
build_slim_model
...
@@ -145,10 +145,16 @@ def main():
...
@@ -145,10 +145,16 @@ def main():
if
'use_npu'
not
in
cfg
:
if
'use_npu'
not
in
cfg
:
cfg
.
use_npu
=
False
cfg
.
use_npu
=
False
# disable xpu in config by default
if
'use_xpu'
not
in
cfg
:
cfg
.
use_xpu
=
False
if
cfg
.
use_gpu
:
if
cfg
.
use_gpu
:
place
=
paddle
.
set_device
(
'gpu'
)
place
=
paddle
.
set_device
(
'gpu'
)
elif
cfg
.
use_npu
:
elif
cfg
.
use_npu
:
place
=
paddle
.
set_device
(
'npu'
)
place
=
paddle
.
set_device
(
'npu'
)
elif
cfg
.
use_xpu
:
place
=
paddle
.
set_device
(
'xpu'
)
else
:
else
:
place
=
paddle
.
set_device
(
'cpu'
)
place
=
paddle
.
set_device
(
'cpu'
)
...
@@ -161,6 +167,7 @@ def main():
...
@@ -161,6 +167,7 @@ def main():
check_config
(
cfg
)
check_config
(
cfg
)
check_gpu
(
cfg
.
use_gpu
)
check_gpu
(
cfg
.
use_gpu
)
check_npu
(
cfg
.
use_npu
)
check_npu
(
cfg
.
use_npu
)
check_xpu
(
cfg
.
use_xpu
)
check_version
()
check_version
()
run
(
FLAGS
,
cfg
)
run
(
FLAGS
,
cfg
)
...
...
tools/train.py
浏览文件 @
35e710c5
...
@@ -144,10 +144,16 @@ def main():
...
@@ -144,10 +144,16 @@ def main():
if
'use_npu'
not
in
cfg
:
if
'use_npu'
not
in
cfg
:
cfg
.
use_npu
=
False
cfg
.
use_npu
=
False
# disable xpu in config by default
if
'use_xpu'
not
in
cfg
:
cfg
.
use_xpu
=
False
if
cfg
.
use_gpu
:
if
cfg
.
use_gpu
:
place
=
paddle
.
set_device
(
'gpu'
)
place
=
paddle
.
set_device
(
'gpu'
)
elif
cfg
.
use_npu
:
elif
cfg
.
use_npu
:
place
=
paddle
.
set_device
(
'npu'
)
place
=
paddle
.
set_device
(
'npu'
)
elif
cfg
.
use_xpu
:
place
=
paddle
.
set_device
(
'xpu'
)
else
:
else
:
place
=
paddle
.
set_device
(
'cpu'
)
place
=
paddle
.
set_device
(
'cpu'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录