Skip to content

Commit

Permalink
Fixed the metric so it works with ROCM librariers. Megvii-BaseDetecti…
Browse files Browse the repository at this point in the history
  • Loading branch information
rpehkone committed Apr 15, 2024
1 parent ac58e0a commit 953037f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions yolox/utils/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@ def get_total_and_free_memory_in_Mb(cuda_device):
"nvidia-smi --query-gpu=memory.total,memory.used --format=csv,nounits,noheader"
)
devices_info = devices_info_str.read().strip().split("\n")
if "CUDA_VISIBLE_DEVICES" in os.environ:
visible_devices = os.environ["CUDA_VISIBLE_DEVICES"].split(',')
cuda_device = int(visible_devices[cuda_device])
total, used = devices_info[int(cuda_device)].split(",")
if len(devices_info) > 1:
if "CUDA_VISIBLE_DEVICES" in os.environ:
visible_devices = os.environ["CUDA_VISIBLE_DEVICES"].split(',')
cuda_device = int(visible_devices[cuda_device])
total, used = devices_info[int(cuda_device)].split(",")
else:
devices_info_str = os.popen(
"rocm-smi --showmeminfo vram --csv"
)
devices_info = devices_info_str.read().strip().split("\n")
_, total, used = devices_info[1].split(',')
total = int(total) // (1024 * 1024)
used = int(used) // (1024 * 1024)

return int(total), int(used)


Expand Down

0 comments on commit 953037f

Please sign in to comment.