# Determine number of workers used

**URL:** <https://discuss.ray.io/t/determine-number-of-workers-used/8498>\
**Category:** Ray Core\
**Created:** [December 1, 2022, 3:41am UTC](https://discuss.ray.io/t/determine-number-of-workers-used/8498 "2022-12-01T03:41:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xzf0kgb0bqr.cev2RWU](https://avatars.discourse-cdn.com/v4/letter/x/65b543/32.png) [@xzf0kgb0bqr.cev2RWU](https://discuss.ray.io/u/xzf0kgb0bqr.cev2RWU)\
**Post date:** [December 1, 2022, 3:41am UTC](https://discuss.ray.io/t/determine-number-of-workers-used/8498/1 "2022-12-01T03:41:36Z")

</div>

Low: It annoys or frustrates me for a moment.

**Question**

I am using a ray.remote function. How can I determine how many workers are created? I have one node with 20 CPUs and I want to make sure that exactly 20 CPUs are being used with 1 worker per CPU.

**Background**

I know I can do @ray.remote(num\_cpus=20), but from [this question](https://discuss.ray.io/t/specify-the-number-of-worker-processes/2118/6), it seems it gives a maximum, while the actual number could be less. My goal is to extract the number of workers/CPUs actually being used.

One way I know is to visualize in the dashboard, but I want to do it programmatically (i.e., assert get\_num\_workers == 20).

**Note**

This is a continuation of [Multiple Ray instances on one node accessing shared memory](https://discuss.ray.io/t/multiple-ray-instances-on-one-node-accessing-shared-memory/8462), and I am specifically interested in the case of the multiply.remote suggested in the solution. However the question is general so the details do not matter.

---

<div class="post-metadata">

**Author:** ![Stephanie\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/stephanie_wang/32/18_2.png) [@Stephanie\_Wang](https://discuss.ray.io/u/Stephanie_Wang)\
**Post date:** [December 1, 2022, 7:53pm UTC](https://discuss.ray.io/t/determine-number-of-workers-used/8498/2 "2022-12-01T19:53:20Z")

</div>

Ray will schedule tasks and start workers based on how many CPUs are requested by each task. If you use the default `@ray.remote` decorator, this will work out to 20 workers and 20 CPUs being used concurrently since `num_cpus` defaults to 1.

Generally you should not need to worry about managing the number of workers yourself, but if you need to check it programmatically for debugging purposes, you can `pgrep` for `ray::`. Ray workers will have the process title format `ray::<currently executing task name or IDLE>`.
