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

Function _is_current_explicit_device

tensorflow/python/keras/backend.py:599–616  ·  view source on GitHub ↗

Check if the current device is explicitly set on the device type specified. Arguments: device_type: A string containing `GPU` or `CPU` (case-insensitive). Returns: A boolean indicating if the current device scope is explicitly set on the device type. Raises: ValueErr

(device_type)

Source from the content-addressed store, hash-verified

597
598
599def _is_current_explicit_device(device_type):
600 """Check if the current device is explicitly set on the device type specified.
601
602 Arguments:
603 device_type: A string containing `GPU` or `CPU` (case-insensitive).
604
605 Returns:
606 A boolean indicating if the current device scope is explicitly set on the
607 device type.
608
609 Raises:
610 ValueError: If the `device_type` string indicates an unsupported device.
611 """
612 device_type = device_type.upper()
613 if device_type not in ['CPU', 'GPU']:
614 raise ValueError('`device_type` should be either "CPU" or "GPU".')
615 device = _get_current_tf_device()
616 return device is not None and device.device_type == device_type.upper()
617
618
619def _get_available_gpus():

Callers 1

_has_nchw_supportFunction · 0.85

Calls 1

_get_current_tf_deviceFunction · 0.85

Tested by

no test coverage detected