Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bbe83ed1
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bbe83ed1
编写于
1月 05, 2022
作者:
Q
Qi Li
提交者:
GitHub
1月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] update XPU run check scripts, test=develop (#38698)
上级
40078103
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
13 deletion
+47
-13
python/CMakeLists.txt
python/CMakeLists.txt
+2
-0
python/paddle/utils/install_check.py
python/paddle/utils/install_check.py
+45
-13
未找到文件。
python/CMakeLists.txt
浏览文件 @
bbe83ed1
...
...
@@ -12,6 +12,8 @@ elseif(WITH_ROCM)
SET
(
PACKAGE_NAME
"paddlepaddle-rocm"
)
elseif
(
WITH_ASCEND_CL
)
SET
(
PACKAGE_NAME
"paddlepaddle-npu"
)
elseif
(
WITH_XPU
)
SET
(
PACKAGE_NAME
"paddlepaddle-xpu"
)
else
()
SET
(
PACKAGE_NAME
"paddlepaddle"
)
endif
()
...
...
python/paddle/utils/install_check.py
浏览文件 @
bbe83ed1
...
...
@@ -89,16 +89,35 @@ def _is_npu_available():
return
False
def
_
run_dygraph_single
(
use_cuda
,
use_npu
):
def
_
is_xpu_available
(
):
"""
Testing the simple network in dygraph mode using one CPU/GPU.
Check whether XPU is avaiable.
"""
try
:
assert
len
(
paddle
.
static
.
xpu_places
())
>
0
return
True
except
Exception
as
e
:
logging
.
warning
(
"You are using XPU version PaddlePaddle, but there is no XPU "
"detected on your machine. Maybe XPU devices is not set properly."
"
\n
Original Error is {}"
.
format
(
e
))
return
False
def
_run_dygraph_single
(
use_cuda
,
use_xpu
,
use_npu
):
"""
Testing the simple network in dygraph mode using one CPU/GPU/XPU/NPU.
Args:
use_cuda (bool): Whether running with CUDA.
use_xpu (bool): Whether running with XPU.
use_npu (bool): Whether running with NPU.
"""
paddle
.
disable_static
()
if
use_cuda
:
paddle
.
set_device
(
'gpu'
)
elif
use_xpu
:
paddle
.
set_device
(
'xpu'
)
elif
use_npu
:
paddle
.
set_device
(
'npu'
)
else
:
...
...
@@ -119,12 +138,14 @@ def _run_dygraph_single(use_cuda, use_npu):
opt
.
step
()
def
_run_static_single
(
use_cuda
,
use_npu
):
def
_run_static_single
(
use_cuda
,
use_
xpu
,
use_
npu
):
"""
Testing the simple network with executor running directly, using one CPU/GPU.
Testing the simple network with executor running directly, using one CPU/GPU
/XPU/NPU
.
Args:
use_cuda (bool): Whether running with CUDA.
use_xpu (bool): Whether running with XPU.
use_npu (bool): Whether running with NPU.
"""
paddle
.
enable_static
()
with
paddle
.
static
.
scope_guard
(
paddle
.
static
.
Scope
()):
...
...
@@ -138,6 +159,8 @@ def _run_static_single(use_cuda, use_npu):
if
use_cuda
:
place
=
paddle
.
CUDAPlace
(
0
)
elif
use_xpu
:
place
=
paddle
.
XPUPlace
(
0
)
elif
use_npu
:
place
=
paddle
.
NPUPlace
(
0
)
else
:
...
...
@@ -151,12 +174,14 @@ def _run_static_single(use_cuda, use_npu):
paddle
.
disable_static
()
def
_run_static_parallel
(
use_cuda
,
use_npu
,
device_list
):
def
_run_static_parallel
(
use_cuda
,
use_
xpu
,
use_
npu
,
device_list
):
"""
Testing the simple network in data parallel mode, using multiple CPU/GPU.
Args:
use_cuda (bool): Whether running with CUDA.
use_xpu (bool): Whether running with XPU.
use_npu (bool): Whether running with NPU.
device_list (int): The specified devices.
"""
paddle
.
enable_static
()
...
...
@@ -175,6 +200,9 @@ def _run_static_parallel(use_cuda, use_npu, device_list):
if
use_cuda
:
place
=
paddle
.
CUDAPlace
(
0
)
elif
use_xpu
:
place
=
paddle
.
XPUPlace
(
0
)
compiled_prog
=
train_prog
elif
use_npu
:
place
=
paddle
.
NPUPlace
(
0
)
compiled_prog
=
train_prog
...
...
@@ -210,19 +238,23 @@ def run_check():
print
(
"Running verify PaddlePaddle program ... "
)
use_cuda
=
False
use_xpu
=
False
use_npu
=
False
if
paddle
.
is_compiled_with_cuda
():
use_cuda
=
_is_cuda_available
()
use_npu
=
False
elif
paddle
.
is_compiled_with_xpu
():
use_xpu
=
_is_xpu_available
()
elif
paddle
.
is_compiled_with_npu
():
use_npu
=
_is_npu_available
()
use_cuda
=
False
else
:
use_npu
=
False
use_cuda
=
False
if
use_cuda
:
device_str
=
"GPU"
device_list
=
paddle
.
static
.
cuda_places
()
elif
use_xpu
:
device_str
=
"XPU"
device_list
=
paddle
.
static
.
xpu_places
()
elif
use_npu
:
device_str
=
"NPU"
device_list
=
paddle
.
static
.
npu_places
()
...
...
@@ -231,12 +263,12 @@ def run_check():
device_list
=
paddle
.
static
.
cpu_places
(
device_count
=
2
)
device_count
=
len
(
device_list
)
_run_static_single
(
use_cuda
,
use_npu
)
_run_dygraph_single
(
use_cuda
,
use_npu
)
_run_static_single
(
use_cuda
,
use_
xpu
,
use_
npu
)
_run_dygraph_single
(
use_cuda
,
use_
xpu
,
use_
npu
)
print
(
"PaddlePaddle works well on 1 {}."
.
format
(
device_str
))
try
:
_run_static_parallel
(
use_cuda
,
use_npu
,
device_list
)
_run_static_parallel
(
use_cuda
,
use_
xpu
,
use_
npu
,
device_list
)
print
(
"PaddlePaddle works well on {} {}s."
.
format
(
device_count
,
device_str
))
print
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录