tf.config.experimental.list_physical_devices

Return a list of physical devices visible to the runtime.

Physical devices are hardware devices locally present on the current machine. By default all discovered CPU and GPU devices are considered visible. The list_physical_devices allows querying the hardware prior to runtime initialization.

The following example ensures the machine can see at least 1 GPU.

physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "No GPUs found."
Args
device_type (optional) Device type to filter by such as "CPU" or "GPU"
Returns
List of PhysicalDevice objects

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/config/experimental/list_physical_devices