# Resource allocation

**URL:** <https://discuss.ray.io/t/resource-allocation/6144>\
**Category:** Ray Core\
**Created:** [May 15, 2022, 3:22pm UTC](https://discuss.ray.io/t/resource-allocation/6144 "2022-05-15T15:22:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome\_Ku](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jerome_ku/32/1474_2.png) [@Jerome\_Ku](https://discuss.ray.io/u/Jerome_Ku)\
**Post date:** [May 15, 2022, 3:22pm UTC](https://discuss.ray.io/t/resource-allocation/6144/1 "2022-05-15T15:22:51Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- Low: It annoys or frustrates me for a moment.

What are the differences in resources allocated at the top level through `ray.init(...)` from at an actor or task level `ray.remote(...)`. E.g., if I allocate `ray.init(num_cpus=4)`, does that mean `ray.remote(num_cpus=x)`, `x <= 4`? Also, how does fractional resource allocation work e…g, `ray.remote(num_gpus=.5)` – I’m assuming you have to specify whole numbers at the top level `ray.init(num_gpus=y)` where `y` is an integer?

---

<div class="post-metadata">

**Author:** ![ericl](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ericl/32/133_2.png) [@ericl](https://discuss.ray.io/u/ericl)\
**Post date:** [May 16, 2022, 12:34am UTC](https://discuss.ray.io/t/resource-allocation/6144/2 "2022-05-16T00:34:58Z")

</div>

Hey @Jerome_Ku , the resources passed to `ray.init()` are manually overriding the number of CPUs / GPUs Ray autodetects for the current machine. Generally, you should only set this for unit testing purposes.

To answer the question, the resources for `ray.remote` are allocation requests (i.e., how many CPUs Ray should reserve for this task), but the ones passed to `ray.init` are defining the available resources (i.e., how many CPUs should this machine be considered to have).

This doc link might also help: [Tips for testing Ray programs — Ray 1.12.0](https://docs.ray.io/en/latest/ray-core/examples/testing-tips.html#tip-1-fixing-the-resource-quantity-with-ray-init-num-cpus)
