Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
a9f9fbad
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a9f9fbad
编写于
5月 23, 2018
作者:
Y
Yu Yang
提交者:
GitHub
5月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10832 from typhoonzero/fix_server_port_file_conflict
fix dist test
上级
8655904b
5fe8de9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
6 deletion
+8
-6
paddle/fluid/operators/listen_and_serv_op.cc
paddle/fluid/operators/listen_and_serv_op.cc
+6
-3
paddle/fluid/operators/listen_and_serv_op.h
paddle/fluid/operators/listen_and_serv_op.h
+1
-2
python/paddle/fluid/tests/unittests/test_dist_train.py
python/paddle/fluid/tests/unittests/test_dist_train.py
+1
-1
未找到文件。
paddle/fluid/operators/listen_and_serv_op.cc
浏览文件 @
a9f9fbad
...
@@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include <stdio.h> // for removing the port file
#include <fstream>
#include <fstream>
#include <ostream>
#include <ostream>
#include <thread> // NOLINT
#include <thread> // NOLINT
...
@@ -77,12 +78,14 @@ ListenAndServOp::ListenAndServOp(const std::string &type,
...
@@ -77,12 +78,14 @@ ListenAndServOp::ListenAndServOp(const std::string &type,
void
ListenAndServOp
::
Stop
()
{
void
ListenAndServOp
::
Stop
()
{
rpc_service_
->
Push
(
LISTEN_TERMINATE_MESSAGE
);
rpc_service_
->
Push
(
LISTEN_TERMINATE_MESSAGE
);
server_thread_
->
join
();
server_thread_
->
join
();
auto
file_path
=
string
::
Sprintf
(
"/tmp/paddle.%d.port"
,
::
getpid
());
remove
(
file_path
.
c_str
());
}
}
void
ListenAndServOp
::
SavePort
(
const
std
::
string
&
file_path
)
const
{
void
ListenAndServOp
::
SavePort
()
const
{
// NOTE: default write file to /tmp/paddle.selected_port
// NOTE: default write file to /tmp/paddle.selected_port
selected_port_
=
rpc_service_
->
GetSelectedPort
();
selected_port_
=
rpc_service_
->
GetSelectedPort
();
auto
file_path
=
string
::
Sprintf
(
"/tmp/paddle.%d.port"
,
::
getpid
());
std
::
ofstream
port_file
;
std
::
ofstream
port_file
;
port_file
.
open
(
file_path
);
port_file
.
open
(
file_path
);
port_file
<<
selected_port_
.
load
();
port_file
<<
selected_port_
.
load
();
...
@@ -331,7 +334,7 @@ void ListenAndServOp::RunImpl(const framework::Scope &scope,
...
@@ -331,7 +334,7 @@ void ListenAndServOp::RunImpl(const framework::Scope &scope,
// Write to a file of server selected port for python use.
// Write to a file of server selected port for python use.
std
::
string
file_path
=
string
::
Sprintf
(
"/tmp/paddle.%d.selected_port"
,
std
::
string
file_path
=
string
::
Sprintf
(
"/tmp/paddle.%d.selected_port"
,
static_cast
<
int
>
(
::
getpid
()));
static_cast
<
int
>
(
::
getpid
()));
SavePort
(
file_path
);
SavePort
();
if
(
sync_mode
)
{
if
(
sync_mode
)
{
RunSyncLoop
(
&
executor
,
program
,
&
recv_scope
,
prefetch_block
);
RunSyncLoop
(
&
executor
,
program
,
&
recv_scope
,
prefetch_block
);
}
else
{
}
else
{
...
...
paddle/fluid/operators/listen_and_serv_op.h
浏览文件 @
a9f9fbad
...
@@ -48,8 +48,7 @@ class ListenAndServOp : public framework::OperatorBase {
...
@@ -48,8 +48,7 @@ class ListenAndServOp : public framework::OperatorBase {
void
RunAsyncLoop
(
framework
::
Executor
*
executor
,
void
RunAsyncLoop
(
framework
::
Executor
*
executor
,
framework
::
ProgramDesc
*
program
)
const
;
framework
::
ProgramDesc
*
program
)
const
;
void
SavePort
(
void
SavePort
()
const
;
const
std
::
string
&
file_path
=
"/tmp/paddle.selected_port"
)
const
;
void
WaitServerReady
();
void
WaitServerReady
();
...
...
python/paddle/fluid/tests/unittests/test_dist_train.py
浏览文件 @
a9f9fbad
...
@@ -34,7 +34,7 @@ class TestSendOp(unittest.TestCase):
...
@@ -34,7 +34,7 @@ class TestSendOp(unittest.TestCase):
p
.
start
()
p
.
start
()
time
.
sleep
(
10
)
time
.
sleep
(
10
)
with
open
(
"/tmp/paddle.%d.
selected_
port"
%
p
.
pid
,
"r"
)
as
fn
:
with
open
(
"/tmp/paddle.%d.port"
%
p
.
pid
,
"r"
)
as
fn
:
selected_port
=
int
(
fn
.
readlines
()[
0
])
selected_port
=
int
(
fn
.
readlines
()[
0
])
self
.
init_client
(
place
,
selected_port
)
self
.
init_client
(
place
,
selected_port
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录