stdout, _ = vm.RemoteCommand("nvidia-smi -L", should_log=True)
try:
gpu_types = []
for line in stdout.splitlines():
if not line:
continue
splitted = line.split(" ")
if splitted[2] == "Tesla":
gpu_types.append(splitted[3])
else:
gpu_types.append(splitted[2])
except:
raise NvidiaSmiParseOutputError("Unable to parse gpu type from {}"
.format(stdout))
if any(gpu_type != gpu_types[0] for gpu_type in gpu_types):
raise HeterogeneousGpuTypesError(
"PKB only supports one type of gpu per VM")
if "K80" in gpu_types[0]:
return NVIDIA_TESLA_K80
if "P4" in gpu_types[0]:
return NVIDIA_TESLA_P4
if "P100" in gpu_types[0]:
return NVIDIA_TESLA_P100
if "V100" in gpu_types[0]:
return NVIDIA_TESLA_V100
if "T4" in gpu_types[0]:
return NVIDIA_TESLA_T4
if "A100" in gpu_types[0]:
return NVIDIA_TESLA_A100
raise UnsupportedClockSpeedError(
"Gpu type {0} is not supported by PKB".format(gpu_types[0]))