Reading number of Ray workers from Python?

I’d like to periodically check the number of ray workers and associated CPUs / RAM available in my cluster from Python.

I know today I can do this from the ray dashboard with:

$ ray dashboard

but I’d like to do it programmatically.

What is the best way to access this information from within a running Ray Python script?

You can use the ray.available_resources() API to check the available resources in the Ray cluster. This is a reflection of the resources that the Ray scheduler has reserved for running tasks and actors. It is not a reflection of actual physical resource utilization.

1 Like