MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _initialize_physical_devices

Method _initialize_physical_devices

tensorflow/python/eager/context.py:1046–1069  ·  view source on GitHub ↗

Get local devices visible to the system.

(self)

Source from the content-addressed store, hash-verified

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.

Callers 8

configMethod · 0.95
list_physical_devicesMethod · 0.95
get_visible_devicesMethod · 0.95
set_visible_devicesMethod · 0.95
get_memory_growthMethod · 0.95
set_memory_growthMethod · 0.95

Calls 4

_import_configMethod · 0.95
PhysicalDeviceClass · 0.85
decodeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected