Ray worker GPU count if GPU available

How severe does this issue affect your experience of using Ray?

  • Low: It annoys or frustrates me for a moment.

Hello everyone,

I have a very simple question. Is there a way to specify that a remote function / worker should use a GPU only if one is available?

I have this code currently, but would like to be able to set the option on the decorator directly without having to do this dynamic lookup.

num_gpus = ray.available_resources().get("GPU")
worker_process = _worker_process.options(num_gpus=num_gpus)

Hey @Mazyod , I am afraid this is not currently a feature that ray supports.

Is there a reason that this lookup is causing troubles other than it being a bit verbose?

1 Like

Thanks for the answer, Ricky. No, it’s not causing any trouble.

I have to admit, it did bite me though.

I am using Ray v1.11, (because of other reasons), and for some reason my worker function (annotated with @ray.remote) uses the GPU anyway on Windows without specifying the num_gpus option. So, I’ve been using this code for a few months without issues.

Recently, I deployed on a linux VM through docker, and the worker wasn’t using the GPU, which made me quite perplexed. I didn’t expect Ray to be the issue, since it was working on Windows, but after eliminating the impossible, the improbable was the truth. Ray behaved differently on Linux, and according to the docs, I had to set the num_gpus, so it’s kinda my fault.