def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
values = ""
counter = 0
length = len(local_device_protos)
for device in local_device_protos:
if device.device_type == "GPU":
description = "Found " + device.physical_device_desc
values += description
if counter < length - 1: values += "\n"
counter += 1
# return [x.name for x in local_device_protos if x.device_type == 'GPU']
return values
# this is taken from the C++ header file
# const int INFO = 0; // base_logging::INFO;
# const int WARNING = 1; // base_logging::WARNING;
# const int ERROR = 2; // base_logging::ERROR;
# const int FATAL = 3; // base_logging::FATAL;
# const int NUM_SEVERITIES = 4; // base_logging::NUM_SEVERITIES;
评论列表
文章目录