未验证 提交 4e1c8f3e 编写于 作者: G gongweibao 提交者: GitHub

Remove psutil dependency. (#26841)

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