Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
f6128777
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看板
提交
f6128777
编写于
3月 13, 2019
作者:
D
dongdaxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add incubate for unified API
上级
317eb0aa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
20 deletion
+37
-20
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+1
-0
python/paddle/fluid/incubate/fleet/base/role_maker.py
python/paddle/fluid/incubate/fleet/base/role_maker.py
+1
-1
python/paddle/fluid/incubate/fleet/parameter_server/__init__.py
.../paddle/fluid/incubate/fleet/parameter_server/__init__.py
+29
-18
python/setup.py.in
python/setup.py.in
+6
-1
未找到文件。
paddle/fluid/pybind/pybind.cc
浏览文件 @
f6128777
...
...
@@ -1358,6 +1358,7 @@ All parameter, weight, gradient are variables in Paddle.
BindRecordIOWriter
(
&
m
);
BindAsyncExecutor
(
&
m
);
BindFleetWrapper
(
&
m
);
BindGraph
(
&
m
);
BindNode
(
&
m
);
BindInferenceApi
(
&
m
);
...
...
python/paddle/fluid/incubate/fleet/base/role_maker.py
浏览文件 @
f6128777
...
...
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.helper
import
MPIHelper
class
RoleMakerBase
(
object
):
...
...
@@ -46,6 +45,7 @@ class MPIRoleMaker(RoleMakerBase):
from
mpi4py
import
MPI
self
.
comm_
=
MPI
.
COMM_WORLD
self
.
MPI
=
MPI
self
.
ips_
=
None
def
get_rank
(
self
):
self
.
rank_
=
self
.
comm_
.
Get_rank
()
...
...
python/paddle/fluid/incubate/fleet/parameter_server/__init__.py
浏览文件 @
f6128777
...
...
@@ -14,19 +14,10 @@
import
sys
import
os
from
..base.role_maker
import
MPISymetricRoleMaker
from
paddle.fluid.optimizer
import
Optimizer
# this is a temporary solution
# TODO(guru4elephant)
# will make this more flexible for more Parameter Server Archs
fleet_instance
=
Fleet
()
init
=
fleet_instance
.
init
stop
=
fleet_instance
.
stop
init_pserver
=
fleet_instance
.
init_pserver
init_worker
=
fleet_instance
.
init_worker
init_pserver_model
=
fleet_instance
.
init_pserver_model
save_pserver_model
=
fleet_instance
.
save_pserver_model
from
.optimizer_factory
import
*
from
google.protobuf
import
text_format
import
paddle.fluid.optimizer
as
local_optimizer
import
paddle.fluid
as
fluid
class
Fleet
(
object
):
...
...
@@ -35,7 +26,7 @@ class Fleet(object):
"""
def
__init__
(
self
):
self
.
opt_info
=
None
# for fleet only
self
.
_
opt_info
=
None
# for fleet only
self
.
role_maker_
=
None
def
init
(
self
):
...
...
@@ -44,7 +35,7 @@ class Fleet(object):
# we will support more configurable RoleMaker for users in the future
self
.
role_maker_
=
MPISymetricRoleMaker
()
self
.
role_maker_
.
generate_role
()
self
.
_fleet_ptr
=
core
.
FleetWrapper
()
self
.
_fleet_ptr
=
fluid
.
core
.
Fleet
()
def
stop
(
self
):
self
.
role_maker_
.
barrier_worker
()
...
...
@@ -91,6 +82,12 @@ class Fleet(object):
print
(
"You should run DistributedOptimizer.minimize() first"
)
sys
.
exit
(
-
1
)
def
is_worker
(
self
):
return
self
.
role_maker_
.
is_worker
()
def
is_server
(
self
):
return
self
.
role_maker_
.
is_server
()
def
init_pserver_model
(
self
):
if
self
.
role_maker_
.
is_first_worker
():
self
.
_fleet_ptr
.
init_model
()
...
...
@@ -103,7 +100,7 @@ class Fleet(object):
self
.
_opt_info
=
opt_info
class
DistributedOptimizer
(
paddle
.
fluid
.
Optimizer
):
class
DistributedOptimizer
(
object
):
def
__init__
(
self
,
optimizer
,
dist_config
=
{}):
super
(
DistributedOptimizer
,
self
).
__init__
()
self
.
_optimizer
=
optimizer
...
...
@@ -115,7 +112,7 @@ class DistributedOptimizer(paddle.fluid.Optimizer):
sys
.
stderr
)
self
.
_optimizer_name
=
"DistributedAdam"
self
.
_distributed_optimizer
=
globals
()[
self
.
_optimizer_name
]()
self
.
_distributed_optimizer
=
globals
()[
self
.
_optimizer_name
](
optimizer
)
def
backward
(
self
,
loss
,
...
...
@@ -135,7 +132,6 @@ class DistributedOptimizer(paddle.fluid.Optimizer):
no_grad_set
=
None
):
optimize_ops
,
param_grads
,
opt_info
=
\
self
.
_distributed_optimizer
.
minimize
(
self
.
_optimizer
,
loss
,
startup_program
,
parameter_list
,
...
...
@@ -143,3 +139,18 @@ class DistributedOptimizer(paddle.fluid.Optimizer):
fleet_instance
.
_set_opt_info
(
opt_info
)
return
[
optimize_ops
,
param_grads
]
# this is a temporary solution
# TODO(guru4elephant)
# will make this more flexible for more Parameter Server Archs
fleet_instance
=
Fleet
()
init
=
fleet_instance
.
init
stop
=
fleet_instance
.
stop
init_pserver
=
fleet_instance
.
init_pserver
init_worker
=
fleet_instance
.
init_worker
is_worker
=
fleet_instance
.
is_worker
is_server
=
fleet_instance
.
is_server
init_pserver_model
=
fleet_instance
.
init_pserver_model
save_pserver_model
=
fleet_instance
.
save_pserver_model
python/setup.py.in
浏览文件 @
f6128777
...
...
@@ -120,7 +120,12 @@ packages=['paddle',
'paddle.fluid.contrib.slim.distillation',
'paddle.fluid.contrib.utils',
'paddle.fluid.transpiler',
'paddle.fluid.transpiler.details']
'paddle.fluid.transpiler.details',
'paddle.fluid.incubate',
'paddle.fluid.incubate.fleet',
'paddle.fluid.incubate.fleet.base',
'paddle.fluid.incubate.fleet.parameter_server',
'paddle.fluid.incubate.fleet.p2p']
with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f:
setup_requires = f.read().splitlines()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录