Try to gather NVidia GPU device information via /proc/driver.
()
| 27 | |
| 28 | |
| 29 | def _gather_gpu_devices_proc(): |
| 30 | """Try to gather NVidia GPU device information via /proc/driver.""" |
| 31 | dev_info = [] |
| 32 | for f in gfile.Glob("/proc/driver/nvidia/gpus/*/information"): |
| 33 | bus_id = f.split("/")[5] |
| 34 | key_values = dict(line.rstrip().replace("\t", "").split(":", 1) |
| 35 | for line in gfile.GFile(f, "r")) |
| 36 | key_values = dict((k.lower(), v.strip(" ").rstrip(" ")) |
| 37 | for (k, v) in key_values.items()) |
| 38 | info = test_log_pb2.GPUInfo() |
| 39 | info.model = key_values.get("model", "Unknown") |
| 40 | info.uuid = key_values.get("gpu uuid", "Unknown") |
| 41 | info.bus_id = bus_id |
| 42 | dev_info.append(info) |
| 43 | return dev_info |
| 44 | |
| 45 | |
| 46 | class CUDADeviceProperties(ct.Structure): |