Meaning of training with resources

In the following command, what is exactly the meaning of “2”.

 trainable_with_resources = tune.with_resources(trainable, {"cpu": 2})

I was assuming it means that 2 CPU are allocated for a single job in case the job need to run 2 CPUs in parallel. But in the manual, there is the following example that confuses me:

 trainable_with_resources = tune.with_resources(trainable, {"cpu": 0.5})

What does the “0.5” mean here? Any hints would be appreciated

{"cpu": 0.5} here means that ray scheduling will treat that this task needs .5 worth of CPU. So Ray would try to put two such kind of tasks on one CPU. This is just for bookkeeping purposes. Ray trusts what the user provides here instead of trying to automatically profiling the running task to figure out how much CPU is really under usage.

1 Like