I have been trying to run a sample example program on a cluster node ray setup. But i have only setup on a single machine.
Annotated the class with @ray.remote . when i invoked the ray.get(On the class object method)
I see the following exception.
File “/home/sumanthn/elevo-0.0.1/elevo_venv/lib64/python3.6/site-packages/ray/function_manager.py”, line 446, in _load_actor_class_from_local
actor_class = getattr(module, class_name)
AttributeError: module ‘main’ has no attribute ‘Counter’
I have tried adding the my python code path to job_config=ray.job_config.JobConfig(code_search_path=)
But still it doesn’t work
PFA for the logs . Below is my code
import ray
import sys
print(sys.path)
ray.init(address='auto', job_config=ray.job_config.JobConfig(code_search_path=sys.path))
@ray.remote
class Counter(object):
def __init__(self):
self.x = 0
def inc(self):
self.x += 1
def get_value(self):
return self.x
# Create an actor process.
c = Counter.remote()
# Check the actor's counter value.
print(ray.get(c.get_value.remote())) # 0
# Increment the counter twice and check the value again.
c.inc.remote()
c.inc.remote()
print(ray.get(c.get_value.remote())) # 2
Ray version is 1.2.0 . CentOS . It’s a cluster setup , but currently only one node is configured. In my case ray is already started outside this program. It is unable to locate this python class program and run. My question should be how to run a program on ray which is already initialized.
It has worked ! So removing
job_config=ray.job_config.JobConfig(code_search_path=sys.path)
From the ray init worked for me . To summarize , the whole issue . I was getting the error
RuntimeError: Actor Counter failed to be imported from local code.Error Message: module ‘main’ has no attribute ‘Counter’
An unexpected internal error occurred while the worker was executing a task.
Ray version is 1.2.0 . I mentioned job config in ray.init assuming that , ray would pick the current working directory of my code. But it wasn’t working. Removing job config worked for me. Thank you very much @rliaw
Another question related to this , in our project code search path is required because of a cross language reference . Therefore it fails under such circumstances . @rliaw . Any suggestions how to tackle this.