Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ebef6601
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ebef6601
编写于
2月 08, 2021
作者:
G
gongweibao
提交者:
GitHub
2月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Destroy session first. (#30954)
Destroy session first.
上级
500f28ec
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
27 addition
and
11 deletion
+27
-11
paddle/fluid/framework/fleet/ascend_wrapper.h
paddle/fluid/framework/fleet/ascend_wrapper.h
+14
-8
paddle/fluid/pybind/ascend_wrapper_py.cc
paddle/fluid/pybind/ascend_wrapper_py.cc
+3
-0
python/paddle/distributed/fleet/launch.py
python/paddle/distributed/fleet/launch.py
+4
-3
python/paddle/distributed/fleet/meta_optimizers/ascend/ascend_optimizer.py
...tributed/fleet/meta_optimizers/ascend/ascend_optimizer.py
+5
-0
python/paddle/distributed/fleet/meta_optimizers/ascend/ascend_parser.py
...distributed/fleet/meta_optimizers/ascend/ascend_parser.py
+1
-0
未找到文件。
paddle/fluid/framework/fleet/ascend_wrapper.h
浏览文件 @
ebef6601
...
@@ -50,29 +50,35 @@ class AscendInstance {
...
@@ -50,29 +50,35 @@ class AscendInstance {
virtual
~
AscendInstance
()
{}
virtual
~
AscendInstance
()
{}
AscendInstance
()
{}
AscendInstance
()
{}
std
::
map
<
AscendString
,
AscendString
>
GetDefaultInitOptions
()
{
std
::
map
<
AscendString
,
AscendString
>
_
GetDefaultInitOptions
()
{
std
::
map
<
AscendString
,
AscendString
>
init_options
;
std
::
map
<
AscendString
,
AscendString
>
init_options
;
init_options
[
"ge.exec.deviceId"
]
=
"0"
;
init_options
[
"ge.exec.deviceId"
]
=
"0"
;
init_options
[
"ge.graphRunMode"
]
=
"1"
;
init_options
[
"ge.graphRunMode"
]
=
"1"
;
return
init_options
;
return
init_options
;
}
}
std
::
map
<
AscendString
,
AscendString
>
GetDefaultInitSessionOptions
()
{
std
::
map
<
AscendString
,
AscendString
>
_
GetDefaultInitSessionOptions
()
{
std
::
map
<
AscendString
,
AscendString
>
init_options
;
std
::
map
<
AscendString
,
AscendString
>
init_options
;
init_options
[
"a"
]
=
"b"
;
//
init_options["a"] = "b";
init_options
[
"ge.trainFlag"
]
=
"1"
;
//
init_options["ge.trainFlag"] = "1";
return
init_options
;
return
init_options
;
}
}
ge
::
Status
InitGEForUT
()
{
return
ge
::
GEInitialize
(
GetDefaultInitOptions
());
}
ge
::
Status
InitGEForUT
()
{
return
ge
::
GEInitialize
(
_
GetDefaultInitOptions
());
}
void
InitGlobalResouces
()
{
void
InitGlobalResouces
()
{
LOG
(
INFO
)
<<
"Begin InitGlobalResouces"
;
LOG
(
INFO
)
<<
"Begin
ascend
InitGlobalResouces"
;
session_
.
reset
(
new
ge
::
Session
(
GetDefaultInitSessionOptions
()));
session_
.
reset
(
new
ge
::
Session
(
_
GetDefaultInitSessionOptions
()));
if
(
session_
==
nullptr
)
{
if
(
session_
==
nullptr
)
{
LOG
(
FATAL
)
<<
"new session error:"
<<
session_
;
LOG
(
FATAL
)
<<
"new session error:"
<<
session_
;
}
}
LOG
(
INFO
)
<<
"End InitGlobalResouces"
;
LOG
(
INFO
)
<<
"End ascend InitGlobalResouces"
;
}
void
DestroyGlobalResouces
()
{
LOG
(
INFO
)
<<
"Begin ascend DestroyGlobalResouces"
;
session_
=
nullptr
;
LOG
(
INFO
)
<<
"Begin ascend DestroyGlobalResouces"
;
}
}
static
std
::
shared_ptr
<
AscendInstance
>
GetInstance
()
{
static
std
::
shared_ptr
<
AscendInstance
>
GetInstance
()
{
...
...
paddle/fluid/pybind/ascend_wrapper_py.cc
浏览文件 @
ebef6601
...
@@ -55,6 +55,9 @@ void BindAscendWrapper(py::module *m) {
...
@@ -55,6 +55,9 @@ void BindAscendWrapper(py::module *m) {
.
def
(
"init_global_resources"
,
.
def
(
"init_global_resources"
,
&
framework
::
AscendInstance
::
InitGlobalResouces
,
&
framework
::
AscendInstance
::
InitGlobalResouces
,
py
::
call_guard
<
py
::
gil_scoped_release
>
())
py
::
call_guard
<
py
::
gil_scoped_release
>
())
.
def
(
"destroy_global_resources"
,
&
framework
::
AscendInstance
::
DestroyGlobalResouces
,
py
::
call_guard
<
py
::
gil_scoped_release
>
())
.
def
(
"add_ascend_subgraph"
,
&
framework
::
AscendInstance
::
AddAscendSubgraph
,
.
def
(
"add_ascend_subgraph"
,
&
framework
::
AscendInstance
::
AddAscendSubgraph
,
py
::
call_guard
<
py
::
gil_scoped_release
>
());
py
::
call_guard
<
py
::
gil_scoped_release
>
());
}
}
...
...
python/paddle/distributed/fleet/launch.py
浏览文件 @
ebef6601
...
@@ -121,8 +121,7 @@ see: http://www.paddlepaddle.org/documentation/docs/zh/1.6/user_guides/howto/tra
...
@@ -121,8 +121,7 @@ see: http://www.paddlepaddle.org/documentation/docs/zh/1.6/user_guides/howto/tra
"--run_mode"
,
"--run_mode"
,
type
=
str
,
type
=
str
,
default
=
"collective"
,
default
=
"collective"
,
help
=
"run mode of job, can be:collective/ps/ps-heter"
help
=
"run mode of job, can be:collective/ps/ps-heter"
)
)
base_group
.
add_argument
(
base_group
.
add_argument
(
"--ascend_npus"
,
"--ascend_npus"
,
...
@@ -133,7 +132,6 @@ see: http://www.paddlepaddle.org/documentation/docs/zh/1.6/user_guides/howto/tra
...
@@ -133,7 +132,6 @@ see: http://www.paddlepaddle.org/documentation/docs/zh/1.6/user_guides/howto/tra
"--ascend_npus=
\"
0,1,2,3
\"
will launch four training processes each bound to one gpu."
"--ascend_npus=
\"
0,1,2,3
\"
will launch four training processes each bound to one gpu."
)
)
base_group
.
add_argument
(
"--selected_gpus"
,
dest
=
"gpus"
)
base_group
.
add_argument
(
"--selected_gpus"
,
dest
=
"gpus"
)
base_group
.
add_argument
(
base_group
.
add_argument
(
...
@@ -250,6 +248,9 @@ def launch_collective(args):
...
@@ -250,6 +248,9 @@ def launch_collective(args):
log_dir
=
args
.
log_dir
,
log_dir
=
args
.
log_dir
,
envs
=
global_envs
)
envs
=
global_envs
)
for
idx
,
proc
in
enumerate
(
procs
):
print
(
"launch proc_id:{} idx:{}"
.
format
(
proc
.
proc
.
pid
,
idx
))
while
True
:
while
True
:
alive
=
watch_local_trainers
(
procs
,
cluster
.
trainers_nranks
())
alive
=
watch_local_trainers
(
procs
,
cluster
.
trainers_nranks
())
...
...
python/paddle/distributed/fleet/meta_optimizers/ascend/ascend_optimizer.py
浏览文件 @
ebef6601
...
@@ -182,9 +182,14 @@ class AscendOptimizer(Optimizer):
...
@@ -182,9 +182,14 @@ class AscendOptimizer(Optimizer):
def
__init__
(
self
,
optimizer
,
fetch_list
=
[]):
def
__init__
(
self
,
optimizer
,
fetch_list
=
[]):
self
.
inner_opt
=
optimizer
self
.
inner_opt
=
optimizer
self
.
fetch_list
=
fetch_list
self
.
fetch_list
=
fetch_list
self
.
ascend_instance
=
None
def
__del__
(
self
):
def
__del__
(
self
):
print
(
"begin AscendOptimizer del"
)
if
self
.
ascend_instance
is
not
None
:
self
.
ascend_instance
.
destroy_global_resources
()
core
.
ge_finalize
()
core
.
ge_finalize
()
print
(
"end AscendOptimizer del"
)
def
_can_apply
(
self
):
def
_can_apply
(
self
):
if
not
self
.
user_defined_strategy
.
ascend
:
if
not
self
.
user_defined_strategy
.
ascend
:
...
...
python/paddle/distributed/fleet/meta_optimizers/ascend/ascend_parser.py
浏览文件 @
ebef6601
...
@@ -16,6 +16,7 @@ from paddle.fluid.optimizer import Optimizer
...
@@ -16,6 +16,7 @@ from paddle.fluid.optimizer import Optimizer
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
numpy
as
np
import
numpy
as
np
from
paddle.distributed
import
fleet
from
paddle.distributed
import
fleet
from
functools
import
reduce
registerd_op
=
{
## forwards
registerd_op
=
{
## forwards
"elementwise_add"
:
"AddParser"
,
"elementwise_add"
:
"AddParser"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录