# How can I assign a ray actor to a specific gpu?

**URL:** <https://discuss.ray.io/t/how-can-i-assign-a-ray-actor-to-a-specific-gpu/15699>\
**Category:** Uncategorized\
**Created:** [August 30, 2024, 7:57am UTC](https://discuss.ray.io/t/how-can-i-assign-a-ray-actor-to-a-specific-gpu/15699 "2024-08-30T07:57:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincentccc](https://avatars.discourse-cdn.com/v4/letter/v/49beb7/32.png) [@vincentccc](https://discuss.ray.io/u/vincentccc)\
**Post date:** [August 30, 2024, 7:57am UTC](https://discuss.ray.io/t/how-can-i-assign-a-ray-actor-to-a-specific-gpu/15699/1 "2024-08-30T07:57:22Z")

</div>

I want to specifically set a actor to a GPU device, with out set CUDA\_VISIBALE\_DEVICES, how can I do this? BTW, I found the the assignment schedule is not round robin, there are some randomness.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/a/a64de082abf0401a65ffc1a589af26106af1761c.png)

````auto
@ray.remote(num_gpus=0.25)
class Worker:
    def __init__ (self):
        pass
        
    def show(self):
        self.gpu_id = ray.get_gpu_ids()[0]
        print(f"#GPU{self.gpu_id}")

        return self.gpu_id

worker_0 = Worker.options(num_gpus=0.25).remote()
worker_1 = Worker.options(num_gpus=0.25).remote()
worker_2 = Worker.options(num_gpus=0.25).remote()
worker_3 = Worker.options(num_gpus=0.25).remote()
worker_4 = Worker.options(num_gpus=0.25).remote()
worker_5 = Worker.options(num_gpus=0.25).remote()
worker_6 = Worker.options(num_gpus=0.25).remote()
worker_7 = Worker.options(num_gpus=0.25).remote()

worker_0 = ray.get(worker_0.show.remote())
worker_1 = ray.get(worker_1.show.remote())
worker_2 = ray.get(worker_2.show.remote())
worker_3 = ray.get(worker_3.show.remote())
worker_4 = ray.get(worker_4.show.remote())
worker_5 = ray.get(worker_5.show.remote())
worker_6 = ray.get(worker_6.show.remote())
worker_7 = ray.get(worker_7.show.remote())

print([worker_0, worker_1,worker_2,worker_3,worker_4,worker_5,worker_6,worker_7])```
````

---

<div class="post-metadata">

**Author:** ![Sam\_Chan](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sam_chan/32/5011_2.png) [@Sam\_Chan](https://discuss.ray.io/u/Sam_Chan)\
**Post date:** [September 4, 2024, 9:29pm UTC](https://discuss.ray.io/t/how-can-i-assign-a-ray-actor-to-a-specific-gpu/15699/2 "2024-09-04T21:29:45Z")

</div>

See here regarding how the Ray Scheduler… well works 😉

[https://docs.ray.io/en/latest/ray-core/scheduling/index.html#scheduling-strategies](https://docs.ray.io/en/latest/ray-core/scheduling/index.html#scheduling-strategies)
