Get a list of available gpu devices (formatted as strings). Returns: A list of available GPU devices.
()
| 617 | |
| 618 | |
| 619 | def _get_available_gpus(): |
| 620 | """Get a list of available gpu devices (formatted as strings). |
| 621 | |
| 622 | Returns: |
| 623 | A list of available GPU devices. |
| 624 | """ |
| 625 | if ops.executing_eagerly_outside_functions(): |
| 626 | # Returns names of devices directly. |
| 627 | return [name for name in context.list_devices() if 'GPU' in name] |
| 628 | |
| 629 | global _LOCAL_DEVICES |
| 630 | if _LOCAL_DEVICES is None: |
| 631 | _LOCAL_DEVICES = get_session().list_devices() |
| 632 | return [x.name for x in _LOCAL_DEVICES if x.device_type == 'GPU'] |
| 633 | |
| 634 | |
| 635 | def _has_nchw_support(): |
no test coverage detected