Enhance GPU memory settings (#5604)

This commit is contained in:
Liangsheng Yin
2025-04-22 06:15:00 +08:00
committed by GitHub
parent bf98d2e377
commit e69a219074
4 changed files with 59 additions and 31 deletions

View File

@@ -1160,6 +1160,20 @@ def get_hpu_memory_capacity():
)
def get_whatever_gpu_memory_capacity(device: str = None):
if is_cuda():
gpu_mem = get_nvgpu_memory_capacity()
elif is_hip():
gpu_mem = get_amdgpu_memory_capacity()
elif device == "hpu":
gpu_mem = get_hpu_memory_capacity()
else:
# GPU memory is not known yet or no GPU is available.
gpu_mem = None
return gpu_mem
# Copy from pytorch and OpenRLHF to allow creating multiple main groups.
# https://github.com/pytorch/pytorch/blob/main/torch/distributed/distributed_c10d.py
# https://github.com/OpenRLHF/OpenRLHF/blob/main/openrlhf/utils/distributed_util.py