What's the replacement for `ray.get_resource_ids `?

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']]
        cpus = []
        # raise ValueError(f'No cpu is available')

I’ll be thrilled to learn if it’s the right thing to do.

cc @rliaw @Alex do you know what we are doing now here?

ray 1.3 still have get_resource_ids. It disappears in ray.1.4

Seems like these are deleted because they were not a part of public API (https://github.com/ray-project/ray/pull/15440). You can still access the method using ray.worker.get_resource_ids I think. Let me follow up with what’s the official public APIs to use to achieve the same thing now.

1 Like