From 129007276408568ddc3fc1852e0548f8708f4f9f Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Thu, 11 Jan 2018 11:09:01 -0800 Subject: [PATCH] [rllib] Expose PPO evaluator resource requirements (#1391) --- build.sh | 2 +- python/ray/rllib/ppo/ppo.py | 9 +++++++-- python/ray/rllib/ppo/ppo_evaluator.py | 3 --- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index b5e5a2b70..47e84e1d2 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ popd bash "$ROOT_DIR/src/thirdparty/download_thirdparty.sh" bash "$ROOT_DIR/src/thirdparty/build_thirdparty.sh" $PYTHON_EXECUTABLE -# Now build everything. +# Now we build everything. pushd "$ROOT_DIR/python/ray/core" # We use these variables to set PKG_CONFIG_PATH, which is important so that # in cmake, pkg-config can find plasma. diff --git a/python/ray/rllib/ppo/ppo.py b/python/ray/rllib/ppo/ppo.py index 184988f22..841386d2b 100644 --- a/python/ray/rllib/ppo/ppo.py +++ b/python/ray/rllib/ppo/ppo.py @@ -14,7 +14,7 @@ import ray from ray.tune.result import TrainingResult from ray.rllib.agent import Agent from ray.rllib.utils import FilterManager -from ray.rllib.ppo.ppo_evaluator import PPOEvaluator, RemotePPOEvaluator +from ray.rllib.ppo.ppo_evaluator import PPOEvaluator from ray.rllib.ppo.rollout import collect_samples @@ -67,6 +67,8 @@ DEFAULT_CONFIG = { "min_steps_per_task": 1000, # Number of actors used to collect the rollouts "num_workers": 5, + # Resource requirements for remote actors + "worker_resources": {"num_cpus": 1}, # Dump TensorFlow timeline after this many SGD minibatches "full_trace_nth_sgd_batch": -1, # Whether to profile data loading @@ -85,7 +87,8 @@ DEFAULT_CONFIG = { class PPOAgent(Agent): _agent_name = "PPO" - _allow_unknown_subkeys = ["model", "tf_session_args", "env_config"] + _allow_unknown_subkeys = ["model", "tf_session_args", "env_config", + "worker_resources"] _default_config = DEFAULT_CONFIG def _init(self): @@ -93,6 +96,8 @@ class PPOAgent(Agent): self.kl_coeff = self.config["kl_coeff"] self.local_evaluator = PPOEvaluator( self.registry, self.env_creator, self.config, self.logdir, False) + RemotePPOEvaluator = ray.remote( + **self.config["worker_resources"])(PPOEvaluator) self.remote_evaluators = [ RemotePPOEvaluator.remote( self.registry, self.env_creator, self.config, self.logdir, diff --git a/python/ray/rllib/ppo/ppo_evaluator.py b/python/ray/rllib/ppo/ppo_evaluator.py index e559b354d..7eb0291e2 100644 --- a/python/ray/rllib/ppo/ppo_evaluator.py +++ b/python/ray/rllib/ppo/ppo_evaluator.py @@ -239,6 +239,3 @@ class PPOEvaluator(Evaluator): if flush_after: f.clear_buffer() return return_filters - - -RemotePPOEvaluator = ray.remote(PPOEvaluator)