[PP] Fix init_memory_pool desync & add PP for mixtral (#6223)
This commit is contained in:
@@ -282,7 +282,9 @@ def calculate_time(show=False, min_cost_ms=0.0):
|
||||
return wrapper
|
||||
|
||||
|
||||
def get_available_gpu_memory(device, gpu_id, distributed=False, empty_cache=True):
|
||||
def get_available_gpu_memory(
|
||||
device, gpu_id, distributed=False, empty_cache=True, cpu_group=None
|
||||
):
|
||||
"""
|
||||
Get available memory for cuda:gpu_id device.
|
||||
When distributed is True, the available memory is the minimum available memory of all GPUs.
|
||||
@@ -344,10 +346,10 @@ def get_available_gpu_memory(device, gpu_id, distributed=False, empty_cache=True
|
||||
free_gpu_memory, total_gpu_memory = torch.npu.mem_get_info()
|
||||
|
||||
if distributed:
|
||||
tensor = torch.tensor(free_gpu_memory, dtype=torch.float32).to(
|
||||
torch.device(device, gpu_id)
|
||||
tensor = torch.tensor(free_gpu_memory, dtype=torch.float32)
|
||||
torch.distributed.all_reduce(
|
||||
tensor, op=torch.distributed.ReduceOp.MIN, group=cpu_group
|
||||
)
|
||||
torch.distributed.all_reduce(tensor, op=torch.distributed.ReduceOp.MIN)
|
||||
free_gpu_memory = tensor.item()
|
||||
|
||||
return free_gpu_memory / (1 << 30)
|
||||
|
||||
Reference in New Issue
Block a user