Discussions>How to find out available GPUs in Tensorflow?>

How to find out available GPUs in Tensorflow?

I've got a service, which runs a script on one of the available gpus, but can't find a way how to detect available gpus on the pc.

2 votesJO242.00
1 Answers

There is function in tensorflow, which gives available devices, which are visible to it. You can take your gpu info from the list of available devices.

from tensorflow.python.client import device_lib

def get_available_gpus():
    local_device_protos = device_lib.list_local_devices()
    return [x.name for x in local_device_protos if x.device_type == 'GPU']
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?