sample-factory icon indicating copy to clipboard operation
sample-factory copied to clipboard

[question] subset of CPUs

Open eugenevinitsky opened this issue 2 years ago • 1 comments

Is there a way to restrict sample-factory to only use a subset of the CPUs on the machine instead of splitting them all amongst the number of workers? Thanks!

eugenevinitsky avatar Apr 15 '22 13:04 eugenevinitsky

Hi Eugene! There's currently no such feature, but it should be relatively straighforward to add.

You'd need to introduce a new CLI parameter for this, and modify the code here: https://github.com/alex-petrenko/sample-factory/blob/63b055a831ba05024fc9bc5a64b1e9eab9bb27a2/sample_factory/algorithms/appo/actor_worker.py#L728 (i.e. inside set_process_cpu_affinity)

The current logic is to distribute cores between processes evenly if possible. i.e. if you have 20 cores and 20 processes, each one gets one core. if you have 20 cores and 10 processes, each one gets 2 cores.

alex-petrenko avatar Apr 15 '22 21:04 alex-petrenko