# How do I ask Ray to autoscale the resources for tuning?

**URL:** <https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171>\
**Category:** Ray Tune\
**Created:** [March 8, 2021, 9:34pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171 "2021-03-08T21:34:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkmamidi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tkmamidi/32/588_2.png) [@tkmamidi](https://discuss.ray.io/u/tkmamidi)\
**Post date:** [March 8, 2021, 9:34pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/1 "2021-03-08T21:34:29Z")

</div>

I’m using Ray `tune.run` and would like to know if there is a way to autoscale the resources available for tuning instead of specifically mentioning.  
Thanks!

```
resources_per_trial (dict): Machine resources to allocate per trial,  
        e.g. `{"cpu": 64, "gpu": 8}`. Note that GPUs will not be  
        assigned unless you specify them here. Defaults to 1 CPU and 0  
        GPUs in `Trainable.default_resource_request()`.
```

---

<div class="post-metadata">

**Author:** ![tkmamidi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tkmamidi/32/588_2.png) [@tkmamidi](https://discuss.ray.io/u/tkmamidi)\
**Post date:** [March 8, 2021, 10:35pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/3 "2021-03-08T22:35:05Z")

</div>

@kai  
Any help is appreciated!  
Thanks!

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [March 9, 2021, 4:24am UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/4 "2021-03-09T04:24:55Z")

</div>

What do you mean by autoscale the resources available here?

---

<div class="post-metadata">

**Author:** ![tkmamidi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tkmamidi/32/588_2.png) [@tkmamidi](https://discuss.ray.io/u/tkmamidi)\
**Post date:** [March 9, 2021, 5:35am UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/5 "2021-03-09T05:35:21Z")

</div>

It says that it uses only 1 CPU. How can make it use as many as available without explicitly saying  
`resources_per_trial :{"cpu": 10, "gpu": 0}` ?

FYI, I’m using SLURM to submit jobs.

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [March 9, 2021, 8:19am UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/6 "2021-03-09T08:19:56Z")

</div>

This is 1 CPU per function evaluation (trial). Tune uses all the available CPUs available on your cluster to run parallel function evaluations.

So for example, if you had a 500 CPU cluster, you’ll see 500 parallel function evaluations (each takes 1 CPU).

---

<div class="post-metadata">

**Author:** ![tkmamidi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tkmamidi/32/588_2.png) [@tkmamidi](https://discuss.ray.io/u/tkmamidi)\
**Post date:** [March 9, 2021, 3:11pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/7 "2021-03-09T15:11:29Z")

</div>

Thanks!

If I had 500 CPUs (requested through SLURM) and want to run only 10 trails, is there a way that RAY can divide the available CPUs to each trail?

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [March 9, 2021, 7:10pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/8 "2021-03-09T19:10:11Z")

</div>

What’s the number of CPUs available per machine? If it is 64, you can only allocate at most 64 CPUs per trial.

Keep in mind, more CPUs per trial doesn’t necessarily translate to faster execution.

---

<div class="post-metadata">

**Author:** ![tkmamidi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tkmamidi/32/588_2.png) [@tkmamidi](https://discuss.ray.io/u/tkmamidi)\
**Post date:** [March 9, 2021, 7:26pm UTC](https://discuss.ray.io/t/how-do-i-ask-ray-to-autoscale-the-resources-for-tuning/1171/9 "2021-03-09T19:26:11Z")

</div>

I think there are 24 CPUs per core.  
Thanks for the suggestion!
