I am not sure.
After some fiddling, I removed the @ray.remote
decorator and instead called the
class_ = ray.remote(Class_)
, then intantiated with:
class_actor = class_.remote(*args)
and this worked properly. I believe this moves away from the recommended way to define an actor.
After some debugging, I found that when using the @ray.remote
decorator option, ray tries to pickle the object and wraps the path.to.module.ModelPredictor
class as path.to.module.model_class._<locals>.Class
(something I think ray does to register and apply the actor)
When cloudpickle attempts to call _getattribute(module, name)
deep in its function call stack, the module= ‘path.to.module’ , and the name ends up being 'model_class..Class instead of the correct name ModelPredictor
When I tried modifying in the debugger the name variable, i.e. _getattribute(module, 'ModelPredictor')
, I get no errors.
I updated to ray version 1.4.1, but it still does the same thing.
Most of the traceback is below:
cannot pickle 'InterceptedNumpy' object
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 580, in dump
return Pickler.dump(self, obj)
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 73, in dumps
cp.dump(obj)
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/_private/function_manager.py", line 364, in export_actor_class
"class": pickle.dumps(Class),
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/actor.py", line 680, in _remote
worker.function_actor_manager.export_actor_class(
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/util/tracing/tracing_helper.py", line 367, in _invocation_actor_class_remote_span
return method(self, args, kwargs, *_args, **_kwargs)
File "/opt/conda/envs/env/lib/python3.8/site-packages/ray/actor.py", line 418, in remote
return self._remote(args=args, kwargs=kwargs)
File "/usr/src/app/pipelines/models/nodes.py", line 791, in make_logit_predictions
predictors.append(ModelPredictor.remote(dataset._get_load_path()))