When using the ray framework, there is an option to select the number of CPUs required for this task, as explained here.
Ex:
@ray.remote(num_cpus=4)
def f():
return 1
However this is unclear whether there is going to be actual CPU allocation:
4
CPUs (using for example the CPU affinity, like in the taskset
linux command, or the cpuset
docker argument)num_cpus
only internally, as scheduling metadata. For ex to decide whether he can start a new task requiring 16 cpus, where there are only 10 left. The task will still have access to all the CPUs and can 'use' more CPU time than requested in num_cpus
The option 2 seems more likely, but this is not stated in the documentation. And additionally, there seems to be a kind of option 1 for the GPUs, which makes the intentions of the scheduler unclear:
Ray will automatically set the environment variable CUDA_VISIBLE_DEVICES for that process.
The process is configured to use a certain GPU (but can bypass it, by resetting CUDA_VISIBLE_DEVICES
)
So, how is used num_cpus
in ray?
Good question - for CPUs, the allocation is only used as metadata (option 2). For GPUs, the allocation is both used as metadata and also provides isolation. The docs will be updated very soon (and will update the answer afterwards).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With