Batch heartbeats from node manager together in the monitor. (#3011)

This commit is contained in:
Ujval Misra
2018-11-20 09:52:27 -08:00
committed by Robert Nishihara
parent abdc3b592e
commit b0bfd104f2
13 changed files with 135 additions and 37 deletions
+42 -9
View File
@@ -3,6 +3,7 @@ from __future__ import division
from __future__ import print_function
import collections
import json
import random
import numpy as np
import os
@@ -919,13 +920,16 @@ def test_actor_multiple_gpus_from_multiple_tasks(shutdown_only):
num_local_schedulers=num_local_schedulers,
redirect_output=True,
num_cpus=(num_local_schedulers * [10 * num_gpus_per_scheduler]),
num_gpus=(num_local_schedulers * [num_gpus_per_scheduler]))
num_gpus=(num_local_schedulers * [num_gpus_per_scheduler]),
_internal_config=json.dumps({
"num_heartbeats_timeout": 1000
}))
@ray.remote
def create_actors(n):
def create_actors(i, n):
@ray.remote(num_gpus=1)
class Actor(object):
def __init__(self):
def __init__(self, i, j):
self.gpu_ids = ray.get_gpu_ids()
def get_location_and_ids(self):
@@ -933,15 +937,44 @@ def test_actor_multiple_gpus_from_multiple_tasks(shutdown_only):
ray.worker.global_worker.plasma_client.store_socket_name),
tuple(self.gpu_ids))
# Create n actors.
for _ in range(n):
Actor.remote()
def sleep(self):
time.sleep(100)
ray.get([
create_actors.remote(num_gpus_per_scheduler)
for _ in range(num_local_schedulers)
# Create n actors.
actors = []
for j in range(n):
actors.append(Actor.remote(i, j))
locations = ray.get(
[actor.get_location_and_ids.remote() for actor in actors])
# Put each actor to sleep for a long time to prevent them from getting
# terminated.
for actor in actors:
actor.sleep.remote()
return locations
all_locations = ray.get([
create_actors.remote(i, num_gpus_per_scheduler)
for i in range(num_local_schedulers)
])
# Make sure that no two actors are assigned to the same GPU.
node_names = {
location
for locations in all_locations for location, gpu_id in locations
}
assert len(node_names) == num_local_schedulers
# Keep track of which GPU IDs are being used for each location.
gpus_in_use = {node_name: [] for node_name in node_names}
for locations in all_locations:
for location, gpu_ids in locations:
gpus_in_use[location].extend(gpu_ids)
for node_name in node_names:
assert len(set(gpus_in_use[node_name])) == num_gpus_per_scheduler
@ray.remote(num_gpus=1)
class Actor(object):
def __init__(self):