List local devices visible to the system. This API allows a client to query the devices before they have been initialized by the eager runtime. Additionally a user can filter by device type, to get only CPUs or GPUs. Args: device_type: Optional device type to limit results to
(self, device_type=None)
| 1069 | self._import_config() |
| 1070 | |
| 1071 | def list_physical_devices(self, device_type=None): |
| 1072 | """List local devices visible to the system. |
| 1073 | |
| 1074 | This API allows a client to query the devices before they have been |
| 1075 | initialized by the eager runtime. Additionally a user can filter by device |
| 1076 | type, to get only CPUs or GPUs. |
| 1077 | |
| 1078 | Args: |
| 1079 | device_type: Optional device type to limit results to |
| 1080 | |
| 1081 | Returns: |
| 1082 | List of PhysicalDevice objects. |
| 1083 | """ |
| 1084 | self._initialize_physical_devices() |
| 1085 | |
| 1086 | if device_type is not None: |
| 1087 | return [ |
| 1088 | d for d in self._physical_devices |
| 1089 | if device_type is None or device_type == d.device_type |
| 1090 | ] |
| 1091 | |
| 1092 | return self._physical_devices |
| 1093 | |
| 1094 | def _import_config(self): |
| 1095 | """Import config if passed in during construction. |