适用于ray-0.8.0

  1. 启动ray:

ray start --head --redis-port=6379 --webui-host=0.0.0.0 --include-webui --redis-password 123 --resources='{"head_res": 1}'

  1. 连接ray执行: ```python import ray import time import ray.services

ray.shutdown(exiting_interpreter=False) ray.init(address=”192.168.217.211:6379”, redis_password=”123”)

@ray.remote def f(): time.sleep(0.01) print(ray.services.get_node_ip_address()) return ray.services.get_node_ip_address()

@ray.remote(resources={“head_res”: 1}) def f2(): time.sleep(0.01) print(ray.services.get_node_ip_address()) return ray.services.get_node_ip_address()

Get a list of the IP addresses of the nodes that have joined the cluster.

set(ray.get([f.remote() for _ in range(10)])) ```