是否可以将任务分配给 Ray 中的特定工作人员?

Is it possible to assign a task to a specific worker in Ray?

具体来说,我希望我的参数存储工作器始终在 HEAD 节点上调用,而不是在任何工作器上调用。这样我就可以优化资源配置。目前参数存储任务似乎在随机服务器上启动,即使它先调用,即使它后面跟着 ray.get()

也许可以这样做: ps = ParameterStore.remote(onHead=True)?

您可以使用额外的自定义资源启动 "head" 节点,然后您可以使参数存储 actor 需要该自定义资源。例如,启动头节点:

ray start --head --resources='{"PSResource": 1}'

然后你可以用

声明参数store actor class
@ray.remote(resources={"PSResource": 1})
class ParameterStore(object):
    pass


ps = ParameterStore.remote()

您还可以定期声明参数存储actor 并更改调用它的方式。例如,

@ray.remote
class ParameterStore(object):
    pass


ps = ParameterStore._remote(args=[], resources={"PSResource": 1})

您可以在 https://ray.readthedocs.io/en/latest/resources.html 阅读更多关于 Ray 资源的信息。