未验证 提交 2697f72b 编写于 作者: G gongweibao 提交者: GitHub

fix release/2.0-beta (#26926)

上级 74d6e2e8
...@@ -15,7 +15,8 @@ from multiprocessing import Pool, Process ...@@ -15,7 +15,8 @@ from multiprocessing import Pool, Process
import os import os
import socket import socket
from contextlib import closing from contextlib import closing
import psutil import time
import sys
def launch_func(func, env_dict): def launch_func(func, env_dict):
...@@ -25,19 +26,36 @@ def launch_func(func, env_dict): ...@@ -25,19 +26,36 @@ def launch_func(func, env_dict):
return proc return proc
def wait(procs, timeout=None): def wait(procs, timeout=30):
# wait error = False
decents = [] begin = time.time()
while True:
alive = False
for p in procs:
p.join(timeout=10)
if p.exitcode is None:
alive = True
continue
elif p.exitcode != 0:
error = True
break
if not alive:
break
if error:
break
if timeout is not None and time.time() - begin >= timeout:
error = True
break
for p in procs: for p in procs:
for child in psutil.Process(p.pid).children(recursive=True): if p.is_alive():
decents.append(child) p.terminate()
gone, alive = psutil.wait_procs(decents, timeout=timeout) if error:
for p in alive: sys.exit(1)
p.kill()
for p in gone:
if p.returncode != 0:
sys.exit(1)
def _find_free_port(port_set): def _find_free_port(port_set):
......
...@@ -190,7 +190,7 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase): ...@@ -190,7 +190,7 @@ class TestFleetGraphExecutionMetaOptimizer(unittest.TestCase):
avg_cost = paddle.fluid.layers.mean(x=cost) avg_cost = paddle.fluid.layers.mean(x=cost)
strategy = paddle.distributed.fleet.DistributedStrategy() strategy = paddle.distributed.fleet.DistributedStrategy()
optimizer = paddle.optimizer.SGD(learning_rate=0.01) optimizer = paddle.fluid.optimizer.SGD(learning_rate=0.01)
optimizer = fleet.distributed_optimizer( optimizer = fleet.distributed_optimizer(
optimizer, strategy=strategy) optimizer, strategy=strategy)
optimizer.minimize(avg_cost) optimizer.minimize(avg_cost)
......
...@@ -21,4 +21,3 @@ objgraph ...@@ -21,4 +21,3 @@ objgraph
astor astor
pathlib pathlib
netifaces netifaces
psutil
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册