Ray.init not work, but ray job submit is

Do you know how I can run this Python script on the Ray cluster without using ray job submit?

from collections import Counter
import socket
import time
import ray ray.init()
@ray.remote 
def f(): 
    time.sleep(0.001) # Return IP address. 
    return socket.gethostbyname(socket.gethostname())
object_ids = [f.remote() for _ in range(100)] 
ip_addresses = ray.get(object_ids) print(Counter(ip_addresses))

At the moment I use scripts like the following to execute on the cluster. But I would prefer to do it without the script so that I can execute from Spyder, Jupyter or other interactive environments.


export RAY_ADDRESS="[http://192.168.26.185:30002](http://192.168.26.185:30002/)" runtime_env="..."
cd $HOME/PycharmProjects/abcd/
script="scripts/ray/script.py"

ray job submit --runtime-env "$runtime_env" python3.9 "$script"

I get this error:

AssertionError: Module: http does not have ClientBuilder.

I’ve also tried removing http:// from the front of RAY_ADDRESS, and changing http:// to ray://, but neither of those work.

This is what happens if I remove ray://

2024-07-24 08:26:30,908 WARNING utils.py:1401 – Unable to connect to GCS (ray head) at 192.168.26.183:30022. Check that (1) Ray with matching version started successfully at the specified address, (2) this node can reach the specified address, and (3) there is no firewall setting preventing access.
2024-07-24 08:26:37,943 ERROR utils.py:1395 – Failed to connect to GCS. Please check gcs_server.out for more details.

Does ray job submit from jupyter not work; you can execute them there not necessarily from the CLI.

ray job submit connects to the Ray dashboard port (8265 in most cases), while ray.init connects to the Ray GCS (6379 in most cases). The GCS port is typically only available on the Ray head node. Are you running ray.init on the Ray head node?