From 2530eb90dc001160349d7f44d4e8e32b97c4c7a9 Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Tue, 17 Dec 2019 14:55:39 -0800 Subject: [PATCH] Move tf.test.is_gpu_available() to after session init (#6515) * move to after session init * script fixes --- doc/dev/get_contributors.py | 6 +++--- rllib/evaluation/rollout_worker.py | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/dev/get_contributors.py b/doc/dev/get_contributors.py index ed4000b5b..774d6b2f2 100644 --- a/doc/dev/get_contributors.py +++ b/doc/dev/get_contributors.py @@ -26,14 +26,14 @@ Create them at https://github.com/settings/tokens/new def run(access_token, prev_release_commit, curr_release_commit): print("Writing commit descriptions to 'commits.txt'...") check_output( - ("'git log {prev_release_commit}..{curr_release_commit} " + (f"git log {prev_release_commit}..{curr_release_commit} " f"--pretty=format:'%s' > commits.txt"), shell=True) # Generate command cmd = [] cmd.append((f"git log {prev_release_commit}..{curr_release_commit} " - f"--pretty=format:'%s' " - f" | grep -Eo '#(\d+)'")) + f"--pretty=format:\"%s\" " + f" | grep -Eo \"#(\d+)\"")) joined = " && ".join(cmd) cmd = f"bash -c '{joined}'" cmd = shlex.split(cmd) diff --git a/rllib/evaluation/rollout_worker.py b/rllib/evaluation/rollout_worker.py index 10beb3c50..90d5e5bcb 100644 --- a/rllib/evaluation/rollout_worker.py +++ b/rllib/evaluation/rollout_worker.py @@ -329,18 +329,6 @@ class RolloutWorker(EvaluatorInterface): tf.executing_eagerly()): if not tf: raise ImportError("Could not import tensorflow") - if (ray.is_initialized() - and ray.worker._mode() != ray.worker.LOCAL_MODE): - if not ray.get_gpu_ids(): - logger.debug( - "Creating policy evaluation worker {}".format( - worker_index) + - " on CPU (please ignore any CUDA init errors)") - elif not tf.test.is_gpu_available(): - raise RuntimeError( - "GPUs were assigned to this worker by Ray, but " - "TensorFlow reports GPU acceleration is disabled. " - "This could be due to a bad CUDA or TF installation.") with tf.Graph().as_default(): if tf_session_creator: self.tf_sess = tf_session_creator() @@ -354,6 +342,18 @@ class RolloutWorker(EvaluatorInterface): tf.set_random_seed(seed) self.policy_map, self.preprocessors = \ self._build_policy_map(policy_dict, policy_config) + if (ray.is_initialized() + and ray.worker._mode() != ray.worker.LOCAL_MODE): + if not ray.get_gpu_ids(): + logger.debug( + "Creating policy evaluation worker {}".format( + worker_index) + + " on CPU (please ignore any CUDA init errors)") + elif not tf.test.is_gpu_available(): + raise RuntimeError( + "GPUs were assigned to this worker by Ray, but " + "TensorFlow reports GPU acceleration is disabled. " + "This could be due to a bad CUDA or TF installation.") else: self.policy_map, self.preprocessors = self._build_policy_map( policy_dict, policy_config)