系统信息
操作系统平台和发行版(例如,Linux Ubuntu 16.04):Ubuntu 18.04
Ray 安装自(源代码或二进制文件):binary
射线版本:0.7.3
Python版本:3.7
TensorFlow 版本:tensorflow-gpu 2.0.0rc0
重现的确切命令:
# Importing packages
from time import time
import gym
import tensorflow as tf
import ray
# Creating our initial model
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, input_shape=(24,), activation='relu'),
tf.keras.layers.Dense(4, activation='softmax')
])
# Setting parameters
episodes = 64
env_name = 'BipedalWalker-v2'
# Initializing ray
ray.init(num_cpus=8, num_gpus=1)
# Creating our ray function
@ray.remote
def play(weights):
actor = tf.keras.Sequential([
tf.keras.layers.Dense(64, input_shape=(24,), activation='relu'),
tf.keras.layers.Dense(4, activation='softmax')
])
actor = actor.set_weights(weights)
env = gym.make('BipedalWalker-v2').env
env._max_episode_steps=1e20
obs = env.reset()
for _ in range(1200):
action = actor.predict_classes(obs).flatten()[0]
action = env.action_space.sample()
obs, rt, done, info = env.step(action)
return rt
# Testing ray
start = time()
weights = model.get_weights()
weights = ray.put(weights)
results = ray.get([play.remote(weights) for i in range(episodes)])
ray.shutdown()
print('Ray done after:',time()-start)
描述问题
我正在尝试使用 Ray 使用 Tensorflow 2.0-gpu Keras 演员并行化 OpenAI 健身房环境的推出。每次我尝试使用 @ray.remote 实例化 Keras 模型时,它都会引发递归深度达到错误。我正在关注 Ray 概述的文档,建议传递权重而不是模型。我不确定我在这里做错了什么,有什么想法吗?
源代码/日志
文件“/home/jacob/anaconda3/envs/tf-2.0-gpu/lib/python3.7/site-packages/tensorflow/init.py”,第 50 行,在 getattr 模块 = self._load()
_load module = _importlib.import_module(self.name) 中的文件“/home/jacob/anaconda3/envs/tf-2.0-gpu/lib/python3.7/site-packages/tensorflow/init.py”,第 44 行
RecursionError:超出最大递归深度