MCPcopy
hub / github.com/alibaba/EasyCV / get_num_gpu_per_node

Function get_num_gpu_per_node

easycv/utils/dist_utils.py:38–49  ·  view source on GitHub ↗

get number of gpu per node

()

Source from the content-addressed store, hash-verified

36
37
38def get_num_gpu_per_node():
39 """ get number of gpu per node
40 """
41 rank, world_size = get_dist_info()
42 if world_size == 1:
43 return 1
44 local_rank = int(os.environ.get('LOCAL_RANK', '0'))
45 local_rank_tensor = torch.tensor([local_rank], device='cuda')
46 torch.distributed.all_reduce(local_rank_tensor, op=ReduceOp.MAX)
47 num_gpus = local_rank_tensor.tolist()[0] + 1
48
49 return num_gpus
50
51
52def barrier():

Callers 1

mainFunction · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected