Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
5d7bccb2
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
694
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d7bccb2
编写于
7月 14, 2017
作者:
H
Helin Wang
提交者:
Helin Wang
7月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix golint errors
上级
065e5666
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
14 deletion
+13
-14
go/pserver/client/c/cclient.go
go/pserver/client/c/cclient.go
+6
-6
go/pserver/client/etcd_client.go
go/pserver/client/etcd_client.go
+7
-8
未找到文件。
go/pserver/client/c/cclient.go
浏览文件 @
5d7bccb2
...
@@ -101,11 +101,11 @@ func paddle_new_pserver_client(addrs *C.char, selected int) C.paddle_pserver_cli
...
@@ -101,11 +101,11 @@ func paddle_new_pserver_client(addrs *C.char, selected int) C.paddle_pserver_cli
}
}
//export paddle_new_etcd_pserver_client
//export paddle_new_etcd_pserver_client
func
paddle_new_etcd_pserver_client
(
etcd
_e
ndpoints
*
C
.
char
,
selected
int
)
C
.
paddle_pserver_client
{
func
paddle_new_etcd_pserver_client
(
etcd
E
ndpoints
*
C
.
char
,
selected
int
)
C
.
paddle_pserver_client
{
// TODO(Longfei: use etcd lock to decide which trainer to initialize the parameters)
// TODO(Longfei: use etcd lock to decide which trainer to initialize the parameters)
addr
:=
C
.
GoString
(
etcd
_e
ndpoints
)
addr
:=
C
.
GoString
(
etcd
E
ndpoints
)
etcd
_c
lient
:=
client
.
NewEtcd
(
addr
)
etcd
C
lient
:=
client
.
NewEtcd
(
addr
)
c
:=
client
.
NewClient
(
etcd
_client
,
etcd_c
lient
.
Desired
(),
selector
(
selected
!=
0
))
c
:=
client
.
NewClient
(
etcd
Client
,
etcdC
lient
.
Desired
(),
selector
(
selected
!=
0
))
return
add
(
c
)
return
add
(
c
)
}
}
...
@@ -124,13 +124,13 @@ func paddle_begin_init_params(client C.paddle_pserver_client) C.int {
...
@@ -124,13 +124,13 @@ func paddle_begin_init_params(client C.paddle_pserver_client) C.int {
}
}
//export paddle_init_param
//export paddle_init_param
func
paddle_init_param
(
client
C
.
paddle_pserver_client
,
param
C
.
paddle_parameter
,
param
_config
unsafe
.
Pointer
,
config_l
en
C
.
int
)
C
.
int
{
func
paddle_init_param
(
client
C
.
paddle_pserver_client
,
param
C
.
paddle_parameter
,
param
Config
unsafe
.
Pointer
,
configL
en
C
.
int
)
C
.
int
{
et
:=
pserver
.
ElementType
(
param
.
element_type
)
et
:=
pserver
.
ElementType
(
param
.
element_type
)
name
:=
C
.
GoString
(
param
.
name
)
name
:=
C
.
GoString
(
param
.
name
)
content
:=
cArrayToSlice
(
unsafe
.
Pointer
(
param
.
content
),
int
(
param
.
content_len
))
content
:=
cArrayToSlice
(
unsafe
.
Pointer
(
param
.
content
),
int
(
param
.
content_len
))
pc
:=
pserver
.
ParameterWithConfig
{
pc
:=
pserver
.
ParameterWithConfig
{
Param
:
pserver
.
Parameter
{
Name
:
name
,
ElementType
:
et
,
Content
:
content
},
Param
:
pserver
.
Parameter
{
Name
:
name
,
ElementType
:
et
,
Content
:
content
},
Config
:
cArrayToSlice
(
param
_config
,
int
(
config_l
en
)),
Config
:
cArrayToSlice
(
param
Config
,
int
(
configL
en
)),
}
}
c
:=
get
(
client
)
c
:=
get
(
client
)
err
:=
c
.
InitParam
(
pc
)
err
:=
c
.
InitParam
(
pc
)
...
...
go/pserver/client/etcd_client.go
浏览文件 @
5d7bccb2
...
@@ -12,8 +12,7 @@ import (
...
@@ -12,8 +12,7 @@ import (
)
)
const
(
const
(
// DefaultEtcdTimeout is the default etcd timeout
defaultEtcdTimeout
time
.
Duration
=
5
*
time
.
Second
DefaultEtcdTimeout
time
.
Duration
=
5
*
time
.
Second
)
)
// EtcdClient is used by pserver client that is a part of trainer process.
// EtcdClient is used by pserver client that is a part of trainer process.
...
@@ -48,7 +47,7 @@ func (p *EtcdClient) Desired() int {
...
@@ -48,7 +47,7 @@ func (p *EtcdClient) Desired() int {
psDesired
,
err
=
strconv
.
Atoi
(
string
(
resp
.
Kvs
[
0
]
.
Value
))
psDesired
,
err
=
strconv
.
Atoi
(
string
(
resp
.
Kvs
[
0
]
.
Value
))
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"psDesired %
s
invalid %v"
,
psDesired
,
err
)
log
.
Errorf
(
"psDesired %
d
invalid %v"
,
psDesired
,
err
)
time
.
Sleep
(
p
.
timeout
)
time
.
Sleep
(
p
.
timeout
)
continue
continue
}
}
...
@@ -67,12 +66,12 @@ func (p *EtcdClient) List() []Server {
...
@@ -67,12 +66,12 @@ func (p *EtcdClient) List() []Server {
for
{
for
{
for
i
:=
0
;
i
<
psDesired
;
i
++
{
for
i
:=
0
;
i
<
psDesired
;
i
++
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
p
.
timeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
p
.
timeout
)
cancel
()
psKey
:=
pserver
.
PsPath
+
strconv
.
Itoa
(
i
)
psKey
:=
pserver
.
PsPath
+
strconv
.
Itoa
(
i
)
log
.
Debugf
(
"checking %s"
,
psKey
)
log
.
Debugf
(
"checking %s"
,
psKey
)
resp
,
err
:=
p
.
client
.
Get
(
ctx
,
psKey
)
resp
,
err
:=
p
.
client
.
Get
(
ctx
,
psKey
)
cancel
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Infof
(
"Get psKey=%s error, %v"
,
psKey
,
err
)
log
.
Infof
(
"Get psKey=
%s error, %v"
,
psKey
,
err
)
time
.
Sleep
(
p
.
timeout
)
time
.
Sleep
(
p
.
timeout
)
continue
continue
}
}
...
@@ -107,11 +106,11 @@ func NewEtcd(endpoints string) *EtcdClient {
...
@@ -107,11 +106,11 @@ func NewEtcd(endpoints string) *EtcdClient {
for
{
for
{
cli
,
err
=
clientv3
.
New
(
clientv3
.
Config
{
cli
,
err
=
clientv3
.
New
(
clientv3
.
Config
{
Endpoints
:
ep
,
Endpoints
:
ep
,
DialTimeout
:
D
efaultEtcdTimeout
,
DialTimeout
:
d
efaultEtcdTimeout
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"Init etcd connection failed: %v"
,
err
)
log
.
Errorf
(
"Init etcd connection failed: %v"
,
err
)
time
.
Sleep
(
D
efaultEtcdTimeout
)
time
.
Sleep
(
d
efaultEtcdTimeout
)
continue
continue
}
}
break
break
...
@@ -119,7 +118,7 @@ func NewEtcd(endpoints string) *EtcdClient {
...
@@ -119,7 +118,7 @@ func NewEtcd(endpoints string) *EtcdClient {
log
.
Infof
(
"Connected to etcd: %s
\n
"
,
endpoints
)
log
.
Infof
(
"Connected to etcd: %s
\n
"
,
endpoints
)
client
:=
&
EtcdClient
{
client
:=
&
EtcdClient
{
client
:
cli
,
client
:
cli
,
timeout
:
D
efaultEtcdTimeout
,
timeout
:
d
efaultEtcdTimeout
,
endpoints
:
ep
,
endpoints
:
ep
,
}
}
return
client
return
client
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录