Hey Ravi, a few more suggestions:
But how do you edit this parameter (and others, say
num_cpu
, etc.) in a large project having multiple files?
If I understand your question correctly, you can dynamically override the number of resources a task/actor takes by calling .option()
.
As an example, your script can be updated to launch 5 counters that each require 2 CPUs and 0.2 GPUs by changing the following:
- counters = [Counter.remote() for i in range(2)]
+ counters = [Counter.options(num_cpus=2, num_gpus=0.2).remote() for i in range(5)]
Shouldn’t ray automatically find free memory on the GPU and then allocate the second actor to the same GPU to save resources?
This is a bit complicated since Ray isn’t aware of how much GPU memory is available on the GPU or how much each task/actor needs. If you are able to estimate this ahead of time, you can do something like:
gpu_fraction = estimated_actor_gpu_memory/single_gpu_memory
counters = [Counter.options(num_gpus=gpu_fraction).remote() for i in range(num_counters)]