Ray: [ray] Can't pickle _thread.RLock objects

Created on 31 Jul 2019  Â·  1Comment  Â·  Source: ray-project/ray

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): 8 * Ubuntu 16.04 with 2 GPU per machine
  • Ray installed from (source or binary):binary
  • Ray version:0.7.2
  • Python version:3.6.8
  • Exact command to reproduce:see below

Describe the problem


@ray.remote
def fstep():
for _ in range(128//32):
actions, values, self.states, neglogpacs = self.model.step(self.obs, self.states, self.dones)
return 1
final_sample = ray.get([fstep.remote() for _ in range(32)])

when i run the code there is the problem:
TypeError: can't pickle _thread.RLock objects

if i remove the self.model.step, like that:

@ray.remote
def fstep():
for _ in range(128//32):
print("hello")
return 1
final_sample = ray.get([fstep.remote() for _ in range(32)])

there is no problem
i want to know why there is a problem when i add the above code: actions, values, self.states, neglogpacs = self.model.step(self.obs, self.states, self.dones)

which is a tensorflow model.

Thanks

Source code / logs

Most helpful comment

The issue is that TensorFlow models can't be serialized and shipped from one machine to another. Instead, you should probably create the TensorFlow model inside of the remote function. If that's too heavyweight (in terms of performance), then you should use Ray actors and create the TensorFlow model in the actor constructor.

>All comments

The issue is that TensorFlow models can't be serialized and shipped from one machine to another. Instead, you should probably create the TensorFlow model inside of the remote function. If that's too heavyweight (in terms of performance), then you should use Ray actors and create the TensorFlow model in the actor constructor.

Was this page helpful?
0 / 5 - 0 ratings