skip to Main Content

I am trying to invoke a python remote function from Java, using the exact same code as mentioned here:
https://docs.ray.io/en/latest/ray-core/cross-language.html#java-calling-python

I got this error:

root@<user>-ubuntu:/dev/Ray_Java/target# java -jar Ray_Java-1.0-SNAPSHOT-jar-with-dependencies.jar
2023-01-23 11:00:10,206 INFO RunManager [main]: Ray runtime started @<ip> .
io.ray.api.exception.RayActorException: The actor <id> died unexpectedly before finishing this task.
at io.ray.runtime.object.ObjectSerializer.deserializeActorException(ObjectSerializer.java:257)
at io.ray.runtime.object.ObjectSerializer.deserialize(ObjectSerializer.java:104)
at io.ray.runtime.object.ObjectStore.get(ObjectStore.java:140)
at io.ray.runtime.AbstractRayRuntime.get(AbstractRayRuntime.java:144)
at io.ray.runtime.AbstractRayRuntime.get(AbstractRayRuntime.java:125)
at io.ray.runtime.AbstractRayRuntime.get(AbstractRayRuntime.java:120)
at io.ray.api.Ray.get(Ray.java:98)
at io.ray.runtime.object.ObjectRefImpl.get(ObjectRefImpl.java:77)
at demo.JavaCallPythonDemo.main(JavaCallPythonDemo.java:26)

JavaCallPythonDemo.java:26 is :
Assert.assertEquals(objRef1.get(), 1);

Versions / Dependencies:

OS: Ubuntu 20.04 [LTS],
Python: 3.8.10,
Java: OpenJDK 11.0.17,
Ray: 2.2,
Apache Maven: 3.6.3

I have overwritten ray.conf file and specified run-mode as ‘CLUSTER’, and am running it in a single node cluster
I am using this in a stand-alone maven project and have specified ray-api and ray-runtime dependencies in pom.xml.
I have included maven-assembly plugin and am creating jar of this project using ‘mvn install’ and then later running this jar (having specified JavaCallPythonDemo.java as the main class).

I was able to initialize Ray from Java and run the jar generated by maven successfully. Here’s a code for the same:

package demo;

import io.ray.api.Ray;

public class RayInit {
public static void main(String args[]) {
Ray.init();
System.out.println("is ray initialized: "+Ray.isInitialized());
Ray.shutdown();
}
}

2

Answers


  1. Chosen as BEST ANSWER

    The response from Ray's Git page:

    https://github.com/ray-project/ray/issues/31857


  2. io.ray.api.exception.RayActorException indicates that the target Python actor was dead.

    You can find the logs of the target Python actor to see the death cause. By default, the target Python actor logs are in:
    /tmp/ray/session_latest/logs/python-core-worker-xxxx
    /tmp/ray/session_latest/logs/python-worker-xxxxx.out
    /tmp/ray/session_latest/logs/python-worker-xxxxx.log

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search