In ray.1.0 or the previous version, I can retrieve the cpu resources for an actor using ray.get_resource_ids
. However, I found this method is no longer valid in ray 1.4+. How can I get the cpu resources in ray 1.4+?
PS. I need this method so that I can affine an actor to a specific cpu to avoid potential resource contention, which was previously achieved using the following code
def cpu_affinity():
resources = ray.get_resource_ids()
if 'CPU' in resources:
cpus = [v[0] for v in resources['CPU']]
psutil.Process().cpu_affinity(cpus)
else:
cpus = []
# raise ValueError(f'No cpu is available')
I’ll be thrilled to learn if it’s the right thing to do.