def _collect_gpu_info(run_info):
  """Collect local GPU information by TF device library."""
  gpu_info = {}
  local_device_protos = device_lib.list_local_devices()

  gpu_info["count"] = len([d for d in local_device_protos
                           if d.device_type == "GPU"])
  # The device description usually is a JSON string, which contains the GPU
  # model info, eg:
  # "device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0"
  for d in local_device_protos:
    if d.device_type == "GPU":
      gpu_info["model"] = _parse_gpu_model(d.physical_device_desc)
      # Assume all the GPU connected are same model
      break
  run_info["machine_config"]["gpu_info"] = gpu_info
def _collect_gpu_info ( run_info ) : gpu_info = { } local_device_protos = device_lib . list_local_devices ( ) gpu_info [ "count" ] = len ( [ d for d in local_device_protos if d . device_type == "GPU" ] ) for d in local_device_protos : if d . device_type == "GPU" : gpu_info [ "model" ] = _parse_gpu_model ( d . physical_device_desc ) break run_info [ "machine_config" ] [ "gpu_info" ] = gpu_info
Collect local GPU information by TF device library.