Skip to content

Commit

Permalink
Fix for device config script (#1480)
Browse files Browse the repository at this point in the history
* Fix for device config script

Signed-off-by: Eric Kerfoot <[email protected]>

* [MONAI] python code formatting

Signed-off-by: monai-bot <[email protected]>

Co-authored-by: monai-bot <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
  • Loading branch information
3 people authored Jan 21, 2021
1 parent c9d15f1 commit edbad43
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions monai/config/deviceconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,28 +196,34 @@ def get_gpu_info() -> OrderedDict:
_dict_append(output, "Num GPUs", lambda: num_gpus)

_dict_append(output, "Has CUDA", lambda: bool(torch.cuda.is_available()))

if output["Has CUDA"]:
_dict_append(output, "CUDA version", lambda: torch.version.cuda)
cudnn_ver = torch.backends.cudnn.version()
_dict_append(output, "cuDNN enabled", lambda: bool(cudnn_ver))

if cudnn_ver:
_dict_append(output, "cuDNN version", lambda: cudnn_ver)

if num_gpus > 0:
_dict_append(output, "Current device", torch.cuda.current_device)
if hasattr(torch.cuda, "get_arch_list"): # get_arch_list is new in torch 1.7.1
_dict_append(output, "Library compiled for CUDA architectures", torch.cuda.get_arch_list)

for gpu in range(num_gpus):
_dict_append(output, "Info for GPU", gpu)
gpu_info = torch.cuda.get_device_properties(gpu)
_dict_append(output, "\tName", lambda: gpu_info.name)
_dict_append(output, "\tIs integrated", lambda: bool(gpu_info.is_integrated))
_dict_append(output, "\tIs multi GPU board", lambda: bool(gpu_info.is_multi_gpu_board))
_dict_append(output, "\tMulti processor count", lambda: gpu_info.multi_processor_count)
_dict_append(output, "\tTotal memory (GB)", lambda: round(gpu_info.total_memory / 1024 ** 3, 1))
_dict_append(output, "\tCached memory (GB)", lambda: round(torch.cuda.memory_reserved(gpu) / 1024 ** 3, 1))
_dict_append(output, "\tAllocated memory (GB)", lambda: round(torch.cuda.memory_allocated(gpu) / 1024 ** 3, 1))
_dict_append(output, "\tCUDA capability (maj.min)", lambda: f"{gpu_info.major}.{gpu_info.minor}")
_dict_append(output, f"GPU {gpu} Name", lambda: gpu_info.name)
_dict_append(output, f"GPU {gpu} Is integrated", lambda: bool(gpu_info.is_integrated))
_dict_append(output, f"GPU {gpu} Is multi GPU board", lambda: bool(gpu_info.is_multi_gpu_board))
_dict_append(output, f"GPU {gpu} Multi processor count", lambda: gpu_info.multi_processor_count)
_dict_append(output, f"GPU {gpu} Total memory (GB)", lambda: round(gpu_info.total_memory / 1024 ** 3, 1))
_dict_append(
output, f"GPU {gpu} Cached memory (GB)", lambda: round(torch.cuda.memory_reserved(gpu) / 1024 ** 3, 1)
)
_dict_append(
output, f"GPU {gpu} Allocated memory (GB)", lambda: round(torch.cuda.memory_allocated(gpu) / 1024 ** 3, 1)
)
_dict_append(output, f"GPU {gpu} CUDA capability (maj.min)", lambda: f"{gpu_info.major}.{gpu_info.minor}")

return output

Expand Down

0 comments on commit edbad43

Please sign in to comment.