Skip to content

Commit

Permalink
update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed May 23, 2023
1 parent 7935ee1 commit 84f25f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions watermark/watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,22 @@ def _get_conda_env():
name = os.getenv('CONDA_DEFAULT_ENV', 'n/a')
return {"conda environment": name}


def _get_gpu_info():
try:
gpu_info = []
gpu_info = [""]
py3nvml.nvmlInit()
num_gpus = py3nvml.nvmlDeviceGetCount()
for i in range(num_gpus):
handle = py3nvml.nvmlDeviceGetHandleByIndex(i)
gpu_name = py3nvml.nvmlDeviceGetName(handle)
gpu_info.append(f"GPU {i}: {gpu_name}")
py3nvml.nvmlShutdown()
return {"GPU Info": "\n".join(gpu_info)}
return {"GPU Info": "\n ".join(gpu_info)}

except py3nvml.NVMLError_LibraryNotFound:
return{"GPU Info": "NVIDIA drivers do not appear to be installed on this machine."}
return {"GPU Info": "NVIDIA drivers do not appear "
"to be installed on this machine."}
except:
return{"GPU Info": "GPU information is not available for this machine."}
return {"GPU Info": "GPU information is not "
"available for this machine."}

0 comments on commit 84f25f9

Please sign in to comment.