Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I force task/actor to run on specific Node? using Ray

I know that a group of tasks in ray will connect with the same actor/s and this will cause a lot of IO between the actor/s and the tasks.
I want to know if is there a way to force the actor/s and the tasks to run on the same Node, to optimize the IO connection.

like image 260
oshribr Avatar asked Nov 01 '25 04:11

oshribr


1 Answers

For Ray 1.13, you can use ray.util.scheduling_strategies.NodeAffinitySchedulingStrategy(node_id, soft: bool),

Here is a simple example:

@ray.remote
class Actor:
    pass

# "DEFAULT" scheduling strategy is used (packed onto nodes until reaching a threshold and then spread).
a1 = Actor.remote()

# Zero-CPU (and no other resources) actors are randomly assigned to nodes.
a2 = Actor.options(num_cpus=0).remote()

# Only run the actor on the local node.
a3 = Actor.options(
    scheduling_strategy=NodeAffinitySchedulingStrategy(
        node_id = ray.get_runtime_context().node_id,
        soft = False,
    )
).remote()
like image 150
GoingMyWay Avatar answered Nov 03 '25 12:11

GoingMyWay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!