[tune][minor] Avoid throwing error when gpu check fails (#7362)

This commit is contained in:
Richard Liaw 2020-02-28 11:32:44 -08:00 committed by GitHub
parent f321eaec9b
commit ca40b0fcc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,7 +58,12 @@ class UtilMonitor(Thread):
self.values["ram_util_percent"].append(
float(getattr(psutil.virtual_memory(), "percent")))
if GPUtil is not None:
for gpu in GPUtil.getGPUs():
gpu_list = []
try:
gpu_list = GPUtil.getGPUs()
except Exception:
logger.debug("GPUtil failed to retrieve GPUs.")
for gpu in gpu_list:
self.values["gpu_util_percent" + str(gpu.id)].append(
float(gpu.load))
self.values["vram_util_percent" + str(gpu.id)].append(