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

Remove psutil dependency. (#26841)

上级 0627a319
...@@ -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,18 +26,35 @@ def launch_func(func, env_dict): ...@@ -25,18 +26,35 @@ 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: for p in procs:
for child in psutil.Process(p.pid).children(recursive=True): p.join(timeout=10)
decents.append(child) if p.exitcode is None:
alive = True
gone, alive = psutil.wait_procs(decents, timeout=timeout) continue
for p in alive: elif p.exitcode != 0:
p.kill() error = True
for p in gone: break
if p.returncode != 0:
if not alive:
break
if error:
break
if timeout is not None and time.time() - begin >= timeout:
error = True
break
for p in procs:
if p.is_alive():
p.terminate()
if error:
sys.exit(1) sys.exit(1)
......
...@@ -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.
先完成此消息的编辑!
想要评论请 注册