Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6473e27d
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看板
未验证
提交
6473e27d
编写于
5月 14, 2021
作者:
W
WangXi
提交者:
GitHub
5月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix launch port already in use (#32892)
上级
2d9d8f57
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
10 addition
and
3 deletion
+10
-3
python/paddle/distributed/fleet/launch_utils.py
python/paddle/distributed/fleet/launch_utils.py
+6
-3
python/paddle/fluid/tests/unittests/test_launch_coverage.py
python/paddle/fluid/tests/unittests/test_launch_coverage.py
+4
-0
未找到文件。
python/paddle/distributed/fleet/launch_utils.py
浏览文件 @
6473e27d
...
@@ -12,9 +12,7 @@
...
@@ -12,9 +12,7 @@
# 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.
import
functools
import
logging
import
logging
import
socket
import
time
import
time
import
os
import
os
import
signal
import
signal
...
@@ -27,6 +25,7 @@ from contextlib import closing
...
@@ -27,6 +25,7 @@ from contextlib import closing
import
socket
import
socket
import
warnings
import
warnings
import
six
import
six
import
struct
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
...
@@ -362,6 +361,10 @@ def add_arguments(argname, type, default, help, argparser, **kwargs):
...
@@ -362,6 +361,10 @@ def add_arguments(argname, type, default, help, argparser, **kwargs):
def
find_free_ports
(
num
):
def
find_free_ports
(
num
):
def
__free_port
():
def
__free_port
():
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
s
:
with
closing
(
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
))
as
s
:
# Note(wangxi): Close the connection with a TCP RST instead
# of a TCP FIN, to avoid time_wait state.
s
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_LINGER
,
struct
.
pack
(
'ii'
,
1
,
0
))
s
.
bind
((
''
,
0
))
s
.
bind
((
''
,
0
))
return
s
.
getsockname
()[
1
]
return
s
.
getsockname
()[
1
]
...
@@ -376,7 +379,7 @@ def find_free_ports(num):
...
@@ -376,7 +379,7 @@ def find_free_ports(num):
return
port_set
return
port_set
step
+=
1
step
+=
1
if
step
>
1
00
:
if
step
>
4
00
:
print
(
print
(
"can't find avilable port and use the specified static port now!"
"can't find avilable port and use the specified static port now!"
)
)
...
...
python/paddle/fluid/tests/unittests/test_launch_coverage.py
浏览文件 @
6473e27d
...
@@ -24,6 +24,7 @@ import paddle.fluid as fluid
...
@@ -24,6 +24,7 @@ import paddle.fluid as fluid
from
argparse
import
ArgumentParser
,
REMAINDER
from
argparse
import
ArgumentParser
,
REMAINDER
from
paddle.distributed.utils
import
_print_arguments
,
get_gpus
,
get_cluster_from_args
from
paddle.distributed.utils
import
_print_arguments
,
get_gpus
,
get_cluster_from_args
from
paddle.distributed.fleet.launch_utils
import
find_free_ports
def
_parse_args
():
def
_parse_args
():
...
@@ -115,6 +116,9 @@ class TestCoverage(unittest.TestCase):
...
@@ -115,6 +116,9 @@ class TestCoverage(unittest.TestCase):
args
.
use_paddlecloud
=
True
args
.
use_paddlecloud
=
True
cluster
,
pod
=
get_cluster_from_args
(
args
,
"0"
)
cluster
,
pod
=
get_cluster_from_args
(
args
,
"0"
)
def
test_find_free_ports
(
self
):
find_free_ports
(
2
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录