连接到多个ray.io遥控地址同时连接

发布于 2025-02-01 02:05:33 字数 482 浏览 3 评论 0原文

我有一个运行远程光线任务的服务。 当前,所有任务都在同一射线群集上运行,但是我希望能够在另一个射线群集上运行其他任务。

今天初始化的方式是使用ray.init(address = ray_cluster_1)在初始化服务时,然后在代码中,我使用foo.remote()调用装饰的功能()

是否可以初始化两个地址并确定要拨打哪个地址?

类似:

ray.init(addresses=[ray_cluster_1, ray_cluster_2])

@ray.remote
def foo()
    pass

foo.remote(address=ray_cluster_1)
foo.remote(address=ray_cluster_2)

如果没有,我看到的唯一选择是拥有两种不同的服务,一个射线。建议?

I have a service that runs remote ray tasks.
Currently, all tasks run on the same ray cluster, but I want to be able to run some other tasks on another ray cluster.

The way it's initialized today is using ray.init(address=ray_cluster_1) while initializing the service, and then in the code, I call decorated functions using foo.remote().

Is it possible to initialize two addresses and decide which one to call?

Something like:

ray.init(addresses=[ray_cluster_1, ray_cluster_2])

@ray.remote
def foo()
    pass

foo.remote(address=ray_cluster_1)
foo.remote(address=ray_cluster_2)

if not, the only option that I see is to have two different services, one per ray. Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜清冷一曲。 2025-02-08 02:05:33

雷通过将ray.init作为上下文管理器的输出来对此进行实验支持。

请注意,您必须使用Ray Client连接到射线簇 https://docs.ray.io/en/latest/latest/cluster/ray-client.html#connect-to-multiple-ray-ray-clusters-clusters-profentiment

import ray
# Create a default client.
ray.init("ray://<head_node_host_cluster>:10001")

# Connect to other clusters.
cli1 = ray.init("ray://<head_node_host_cluster_1>:10001", allow_multiple=True)
cli2 = ray.init("ray://<head_node_host_cluster_2>:10001", allow_multiple=True)

# Data is put into the default cluster.
obj = ray.put("obj")

with cli1:
    obj1 = ray.put("obj1")

with cli2:
    obj2 = ray.put("obj2")

Ray has experimental support with this by treating the output of ray.init as a context manager.

Note that you must be using Ray Client to connect to your ray cluster https://docs.ray.io/en/latest/cluster/ray-client.html#connect-to-multiple-ray-clusters-experimental

import ray
# Create a default client.
ray.init("ray://<head_node_host_cluster>:10001")

# Connect to other clusters.
cli1 = ray.init("ray://<head_node_host_cluster_1>:10001", allow_multiple=True)
cli2 = ray.init("ray://<head_node_host_cluster_2>:10001", allow_multiple=True)

# Data is put into the default cluster.
obj = ray.put("obj")

with cli1:
    obj1 = ray.put("obj1")

with cli2:
    obj2 = ray.put("obj2")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文