Skip to content

Commit

Permalink
fix(utils): occupy_mem based on CUDA_VISIBLE_DEVICES (#1139)
Browse files Browse the repository at this point in the history
fix(utils): occupy_mem based on CUDA_VISIBLE_DEVICES
  • Loading branch information
ArMaxik committed Feb 22, 2022
1 parent d99bee0 commit d98da01
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions yolox/utils/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ 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(",")
return int(total), int(used)

Expand Down

0 comments on commit d98da01

Please sign in to comment.