Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
68223077
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
未验证
提交
68223077
编写于
9月 28, 2020
作者:
1
123malin
提交者:
GitHub
9月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test=develop, rm netifaces (#27581)
* test=develop, rm netifaces
上级
9704582e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
48 addition
and
99 deletion
+48
-99
python/paddle/distributed/fleet/base/role_maker.py
python/paddle/distributed/fleet/base/role_maker.py
+21
-14
python/paddle/fluid/incubate/fleet/base/role_maker.py
python/paddle/fluid/incubate/fleet/base/role_maker.py
+21
-14
python/paddle/fluid/tests/unittests/test_fleet.py
python/paddle/fluid/tests/unittests/test_fleet.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_nocvm_1.py
python/paddle/fluid/tests/unittests/test_fleet_nocvm_1.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_rolemaker.py
python/paddle/fluid/tests/unittests/test_fleet_rolemaker.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_2.py
...on/paddle/fluid/tests/unittests/test_fleet_rolemaker_2.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_3.py
...on/paddle/fluid/tests/unittests/test_fleet_rolemaker_3.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_4.py
...on/paddle/fluid/tests/unittests/test_fleet_rolemaker_4.py
+0
-6
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_new.py
.../paddle/fluid/tests/unittests/test_fleet_rolemaker_new.py
+0
-28
python/paddle/fluid/tests/unittests/test_fleet_unitaccessor.py
...n/paddle/fluid/tests/unittests/test_fleet_unitaccessor.py
+1
-5
python/paddle/fluid/tests/unittests/test_fleet_util.py
python/paddle/fluid/tests/unittests/test_fleet_util.py
+0
-5
python/requirements.txt
python/requirements.txt
+0
-2
未找到文件。
python/paddle/distributed/fleet/base/role_maker.py
浏览文件 @
68223077
...
@@ -253,26 +253,33 @@ class Gloo(object):
...
@@ -253,26 +253,33 @@ class Gloo(object):
"""
"""
get default physical interface
get default physical interface
"""
"""
import
netifaces
res
=
os
.
popen
(
"route -A inet"
).
read
().
strip
().
split
(
"
\n
"
)
gateways
=
netifaces
.
gateways
()
if
gateways
.
get
(
netifaces
.
AF_INET
)
!=
None
:
gateway_idx
=
None
gateway
=
gateways
[
netifaces
.
AF_INET
]
iface_idx
=
None
if
len
(
gateway
)
>
0
and
len
(
gateway
[
0
])
>
1
:
for
item
in
res
:
return
gateway
[
0
][
1
]
item
=
item
.
split
()
if
"Gateway"
in
item
and
"Iface"
in
item
:
gateway_idx
=
item
.
index
(
"Gateway"
)
iface_idx
=
item
.
index
(
"Iface"
)
elif
gateway_idx
!=
None
and
iface_idx
!=
None
:
gateway
=
None
if
len
(
item
)
>
gateway_idx
:
gateway
=
item
[
gateway_idx
]
if
gateway
and
gateway
!=
'*'
and
gateway
!=
"0.0.0.0"
and
len
(
item
)
>
iface_idx
:
return
item
[
iface_idx
]
return
"lo"
return
"lo"
def
__get_default_iface_from_interfaces
(
self
):
def
__get_default_iface_from_interfaces
(
self
):
"""
"""
get default physical interface
get default physical interface
"""
"""
import
netifaces
res
=
os
.
popen
(
"ip -f inet addr | awk NR%3==1"
).
read
().
strip
().
split
(
for
intf_name
in
netifaces
.
interfaces
():
"
\n
"
)
addresses
=
netifaces
.
ifaddresses
(
intf_name
)
for
item
in
res
:
if
netifaces
.
AF_INET
in
addresses
:
if
"BROADCAST"
in
item
:
ipv4_addresses
=
addresses
[
netifaces
.
AF_INET
]
return
item
.
split
(
":"
)[
1
].
strip
()
for
ipv4_address
in
ipv4_addresses
:
if
'broadcast'
in
ipv4_address
:
return
intf_name
return
"lo"
return
"lo"
def
barrier
(
self
,
comm_world
):
def
barrier
(
self
,
comm_world
):
...
...
python/paddle/fluid/incubate/fleet/base/role_maker.py
浏览文件 @
68223077
...
@@ -955,26 +955,33 @@ class GeneralRoleMaker(RoleMakerBase):
...
@@ -955,26 +955,33 @@ class GeneralRoleMaker(RoleMakerBase):
"""
"""
get default physical interface
get default physical interface
"""
"""
import
netifaces
res
=
os
.
popen
(
"route -A inet"
).
read
().
strip
().
split
(
"
\n
"
)
gateways
=
netifaces
.
gateways
()
if
gateways
.
get
(
netifaces
.
AF_INET
)
!=
None
:
gateway_idx
=
None
gateway
=
gateways
[
netifaces
.
AF_INET
]
iface_idx
=
None
if
len
(
gateway
)
>
0
and
len
(
gateway
[
0
])
>
1
:
for
item
in
res
:
return
gateway
[
0
][
1
]
item
=
item
.
split
()
if
"Gateway"
in
item
and
"Iface"
in
item
:
gateway_idx
=
item
.
index
(
"Gateway"
)
iface_idx
=
item
.
index
(
"Iface"
)
elif
gateway_idx
!=
None
and
iface_idx
!=
None
:
gateway
=
None
if
len
(
item
)
>
gateway_idx
:
gateway
=
item
[
gateway_idx
]
if
gateway
and
gateway
!=
'*'
and
gateway
!=
"0.0.0.0"
and
len
(
item
)
>
iface_idx
:
return
item
[
iface_idx
]
return
"lo"
return
"lo"
def
__get_default_iface_from_interfaces
(
self
):
def
__get_default_iface_from_interfaces
(
self
):
"""
"""
get default physical interface
get default physical interface
"""
"""
import
netifaces
res
=
os
.
popen
(
"ip -f inet addr | awk NR%3==1"
).
read
().
strip
().
split
(
for
intf_name
in
netifaces
.
interfaces
():
"
\n
"
)
addresses
=
netifaces
.
ifaddresses
(
intf_name
)
for
item
in
res
:
if
netifaces
.
AF_INET
in
addresses
:
if
"BROADCAST"
in
item
:
ipv4_addresses
=
addresses
[
netifaces
.
AF_INET
]
return
item
.
split
(
":"
)[
1
].
strip
()
for
ipv4_address
in
ipv4_addresses
:
if
'broadcast'
in
ipv4_address
:
return
intf_name
return
"lo"
return
"lo"
def
__start_kv_server
(
self
,
http_server_d
,
size_d
):
def
__start_kv_server
(
self
,
http_server_d
,
size_d
):
...
...
python/paddle/fluid/tests/unittests/test_fleet.py
浏览文件 @
68223077
...
@@ -37,11 +37,7 @@ class TestFleet1(unittest.TestCase):
...
@@ -37,11 +37,7 @@ class TestFleet1(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_1"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_nocvm_1.py
浏览文件 @
68223077
...
@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
...
@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_1"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_rolemaker.py
浏览文件 @
68223077
...
@@ -64,11 +64,7 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -64,11 +64,7 @@ class TestCloudRoleMaker(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_1"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_2.py
浏览文件 @
68223077
...
@@ -36,11 +36,7 @@ class TestCloudRoleMaker2(unittest.TestCase):
...
@@ -36,11 +36,7 @@ class TestCloudRoleMaker2(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.distribute_transpiler
import
fleet
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
RoleMakerBase
from
paddle.fluid.incubate.fleet.base.role_maker
import
RoleMakerBase
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_2"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_3.py
浏览文件 @
68223077
...
@@ -36,11 +36,7 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -36,11 +36,7 @@ class TestCloudRoleMaker(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_1"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_4.py
浏览文件 @
68223077
...
@@ -47,12 +47,6 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -47,12 +47,6 @@ class TestCloudRoleMaker(unittest.TestCase):
print
(
"warning: no fleet, skip test_pslib_4"
)
print
(
"warning: no fleet, skip test_pslib_4"
)
return
return
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_4"
)
return
class
FakeStream
():
class
FakeStream
():
"""
"""
it is a fake stream only for test.
it is a fake stream only for test.
...
...
python/paddle/fluid/tests/unittests/test_fleet_rolemaker_new.py
浏览文件 @
68223077
...
@@ -70,12 +70,6 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -70,12 +70,6 @@ class TestCloudRoleMaker(unittest.TestCase):
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"PADDLE_TRAINER_ID"
]
=
"0"
os
.
environ
[
"PADDLE_TRAINER_ID"
]
=
"0"
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_tr_rolemaker"
)
return
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
self
.
assertTrue
(
ro
.
_is_worker
())
self
.
assertTrue
(
ro
.
_is_worker
())
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
...
@@ -110,12 +104,6 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -110,12 +104,6 @@ class TestCloudRoleMaker(unittest.TestCase):
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_ps_rolemaker"
)
return
ro
=
role_maker
.
PaddleCloudRoleMaker
(
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
,
init_gloo
=
False
)
is_collective
=
False
,
init_gloo
=
False
)
self
.
assertEqual
(
ro
.
_server_index
(),
0
)
self
.
assertEqual
(
ro
.
_server_index
(),
0
)
...
@@ -131,11 +119,6 @@ class TestCloudRoleMaker(unittest.TestCase):
...
@@ -131,11 +119,6 @@ class TestCloudRoleMaker(unittest.TestCase):
def
test_traing_role
(
self
):
def
test_traing_role
(
self
):
"""Test training role."""
"""Test training role."""
os
.
environ
[
"TRAINING_ROLE"
]
=
"TEST"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TEST"
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_training_role"
)
return
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
ro
=
role_maker
.
PaddleCloudRoleMaker
(
is_collective
=
False
)
self
.
assertRaises
(
ValueError
,
ro
.
_generate_role
)
self
.
assertRaises
(
ValueError
,
ro
.
_generate_role
)
...
@@ -150,11 +133,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
...
@@ -150,11 +133,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
pass
pass
def
test_ps_rolemaker
(
self
):
def
test_ps_rolemaker
(
self
):
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_ps_rolemaker"
)
return
ro
=
role_maker
.
UserDefinedRoleMaker
(
ro
=
role_maker
.
UserDefinedRoleMaker
(
is_collective
=
False
,
is_collective
=
False
,
...
@@ -169,12 +147,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
...
@@ -169,12 +147,6 @@ class TestUserDefinedRoleMaker(unittest.TestCase):
self
.
assertEqual
(
ro
.
_role_id
(),
0
)
self
.
assertEqual
(
ro
.
_role_id
(),
0
)
def
test_tr_rolemaker
(
self
):
def
test_tr_rolemaker
(
self
):
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_tr_rolemaker"
)
return
ro
=
role_maker
.
UserDefinedRoleMaker
(
ro
=
role_maker
.
UserDefinedRoleMaker
(
is_collective
=
False
,
is_collective
=
False
,
init_gloo
=
False
,
init_gloo
=
False
,
...
...
python/paddle/fluid/tests/unittests/test_fleet_unitaccessor.py
浏览文件 @
68223077
...
@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
...
@@ -36,11 +36,7 @@ class TestFleet1(unittest.TestCase):
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
fleet
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.parameter_server.pslib
import
PSLib
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
from
paddle.fluid.incubate.fleet.base.role_maker
import
GeneralRoleMaker
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_pslib_1"
)
return
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"POD_IP"
]
=
"127.0.0.1"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"PADDLE_PORT"
]
=
"36001"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
os
.
environ
[
"TRAINING_ROLE"
]
=
"TRAINER"
...
...
python/paddle/fluid/tests/unittests/test_fleet_util.py
浏览文件 @
68223077
...
@@ -100,11 +100,6 @@ class TestFleetUtil(unittest.TestCase):
...
@@ -100,11 +100,6 @@ class TestFleetUtil(unittest.TestCase):
def
test_get_file_shard
(
self
):
def
test_get_file_shard
(
self
):
import
paddle.distributed.fleet
as
fleet
import
paddle.distributed.fleet
as
fleet
self
.
assertRaises
(
Exception
,
fleet
.
util
.
get_file_shard
,
"files"
)
self
.
assertRaises
(
Exception
,
fleet
.
util
.
get_file_shard
,
"files"
)
try
:
import
netifaces
except
:
print
(
"warning: no netifaces, skip test_get_file_shard"
)
return
role
=
role_maker
.
UserDefinedRoleMaker
(
role
=
role_maker
.
UserDefinedRoleMaker
(
is_collective
=
False
,
is_collective
=
False
,
...
...
python/requirements.txt
浏览文件 @
68223077
...
@@ -17,5 +17,3 @@ decorator
...
@@ -17,5 +17,3 @@ decorator
prettytable
prettytable
astor
astor
pathlib
pathlib
netifaces ; platform_system != "Windows"
netifaces ; python_version>="3.5" and platform_system == "Windows"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录