# CPU Affinity for Ray Workers

**URL:** <https://discuss.ray.io/t/cpu-affinity-for-ray-workers/1211>\
**Category:** Ray Core\
**Created:** [March 11, 2021, 9:15am UTC](https://discuss.ray.io/t/cpu-affinity-for-ray-workers/1211 "2021-03-11T09:15:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexanderb14](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alexanderb14](https://discuss.ray.io/u/alexanderb14)\
**Post date:** [March 11, 2021, 9:15am UTC](https://discuss.ray.io/t/cpu-affinity-for-ray-workers/1211/1 "2021-03-11T09:15:52Z")

</div>

Hi,

I am using RLlib (based on Ray) and got forwarded to ask the question here (original thread: [CPU Affinity for Workers](https://discuss.ray.io/t/cpu-affinity-for-workers/1179))

I would like to bind workers to specific specific CPU HW threads. Background is that the workers run benchmarks on the CPUs and are not side-effect free in case they are assigned random HW threads (The Ryzen CPU I am using has multiple groups of HW threads, each group shares a common L3 cache that is relevant for the benchmark).

Does Ray Core support this feature? In case not, could you hint me to a good place where to implement this, please?

Many thanks!

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [March 11, 2021, 9:24pm UTC](https://discuss.ray.io/t/cpu-affinity-for-ray-workers/1211/2 "2021-03-11T21:24:59Z")

</div>

Ray doesn’t natively support the cpu affinity. If you’d like to do this, you need to use [psutil documentation — psutil 5.8.1 documentation](https://psutil.readthedocs.io/en/latest/#psutil.Process.cpu_affinity) per each task & actor
