Get local devices visible to the system.
(self)
| 1044 | return _post_execution_callbacks.callbacks |
| 1045 | |
| 1046 | def _initialize_physical_devices(self): |
| 1047 | """Get local devices visible to the system.""" |
| 1048 | # We lazy initialize self._physical_devices since we do not want to do this |
| 1049 | # the constructor since the backend may not be initialized yet. |
| 1050 | with self._device_lock: |
| 1051 | if self._physical_devices is not None: |
| 1052 | return |
| 1053 | |
| 1054 | devs = pywrap_tensorflow.TF_ListPhysicalDevices() |
| 1055 | self._physical_devices = [ |
| 1056 | PhysicalDevice(name=d.decode(), |
| 1057 | device_type=d.decode().split(":")[1]) for d in devs] |
| 1058 | # Construct the visible device list from all physical devices but ignore |
| 1059 | # XLA devices |
| 1060 | self._visible_device_list = [ |
| 1061 | d for d in self._physical_devices |
| 1062 | if not d.device_type.startswith("XLA") |
| 1063 | ] |
| 1064 | self._memory_growth_map = { |
| 1065 | d: None for d in self._physical_devices if d.device_type == "GPU" |
| 1066 | } |
| 1067 | |
| 1068 | # Import device settings that may have been passed into the constructor |
| 1069 | self._import_config() |
| 1070 | |
| 1071 | def list_physical_devices(self, device_type=None): |
| 1072 | """List local devices visible to the system. |
no test coverage detected