# How to assign actors to specific machines?

**URL:** <https://discuss.ray.io/t/how-to-assign-actors-to-specific-machines/13340>\
**Category:** Ray Core\
**Created:** [January 8, 2024, 8:11am UTC](https://discuss.ray.io/t/how-to-assign-actors-to-specific-machines/13340 "2024-01-08T08:11:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![godsakurapeng](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/godsakurapeng/32/5577_2.png) [@godsakurapeng](https://discuss.ray.io/u/godsakurapeng)\
**Post date:** [January 8, 2024, 8:11am UTC](https://discuss.ray.io/t/how-to-assign-actors-to-specific-machines/13340/1 "2024-01-08T08:11:17Z")

</div>

I’m not sure if this is a bug.  
I have **4** machines with **two** gpu. At the same time, I have **5** tasks that require [**2** , **2** , **2** , **1** , **1**] gpu.I have set num\_gpus.  
The situation I envision is that **three** machines deploy **two-gpu** tasks, and one machine deploys **two**  **one-gpu** tasks.  
However, in fact, this allocation seems to be **random**. Sometimes it is allocated according to the scenario I expected. Sometimes **two**  **one-gpu** tasks are distributed on **two machines** , and a **two-gpu** task is also allocated on **two machines**.

During initialization, you can see that **two one-gpu** tasks are distributed on **two machines**.

Because of the problem below, there are no pictures here. I’ll see if I can add them in the comment area.

> _Sorry, new users can only put one embedded media item in a post._

When I call a **two-gpu** GPU infer task, I can see that the task is running on **two machines**.  
Infer is much **slower** due to the need for communication between machines

 ![企业微信截图_17046992631411](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/5/5d9b0e969b9e7cd6f740d96c86b5ea1c60a51090.png)

So, can ray assign actors to specific machines? Or is there any other way? I’m looking forward to the response 🙂

---

<div class="post-metadata">

**Author:** ![godsakurapeng](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/godsakurapeng/32/5577_2.png) [@godsakurapeng](https://discuss.ray.io/u/godsakurapeng)\
**Post date:** [January 8, 2024, 8:12am UTC](https://discuss.ray.io/t/how-to-assign-actors-to-specific-machines/13340/2 "2024-01-08T08:12:18Z")

</div>

![企业微信截图_17046988184600](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/a/aef8405b90cdac46cf4647f1ebf02e8e73005a54.png)  
(add pictures

---

<div class="post-metadata">

**Author:** ![Jules\_Damji](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jules_damji/32/4058_2.png) [@Jules\_Damji](https://discuss.ray.io/u/Jules_Damji)\
**Post date:** [January 8, 2024, 10:51pm UTC](https://discuss.ray.io/t/how-to-assign-actors-to-specific-machines/13340/3 "2024-01-08T22:51:44Z")

</div>

@godsakurapeng Consider using [placement groups](https://docs.ray.io/en/latest/ray-core/scheduling/placement-group.html) to gang schedule them for resource affinity.

Some simple example code: [misc-code/py/ray/placement\_groups at master · dmatrix/misc-code · GitHub](https://github.com/dmatrix/misc-code/tree/master/py/ray/placement_groups)
