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 initializat
(device_type=None)
| 362 | |
| 363 | @tf_export('config.experimental.list_physical_devices') |
| 364 | def list_physical_devices(device_type=None): |
| 365 | """Return a list of physical devices visible to the runtime. |
| 366 | |
| 367 | Physical devices are hardware devices locally present on the current machine. |
| 368 | By default all discovered CPU and GPU devices are considered visible. The |
| 369 | `list_physical_devices` allows querying the hardware prior to runtime |
| 370 | initialization. |
| 371 | |
| 372 | The following example ensures the machine can see at least 1 GPU. |
| 373 | |
| 374 | ```python |
| 375 | physical_devices = tf.config.experimental.list_physical_devices('GPU') |
| 376 | assert len(physical_devices) > 0, "No GPUs found." |
| 377 | ``` |
| 378 | |
| 379 | Args: |
| 380 | device_type: (optional) Device type to filter by such as "CPU" or "GPU" |
| 381 | |
| 382 | Returns: |
| 383 | List of PhysicalDevice objects |
| 384 | """ |
| 385 | return context.context().list_physical_devices(device_type) |
| 386 | |
| 387 | |
| 388 | @tf_export('config.experimental.list_logical_devices') |
nothing calls this directly
no test coverage detected