MCPcopy Create free account
hub / github.com/pytorch/examples / verify_min_gpu_count

Function verify_min_gpu_count

distributed/ddp/example.py:14–18  ·  view source on GitHub ↗

verification that we have at least 2 gpus to run dist examples

(min_gpus: int = 2)

Source from the content-addressed store, hash-verified

12from torch.nn.parallel import DistributedDataParallel as DDP
13
14def verify_min_gpu_count(min_gpus: int = 2) -> bool:
15 """ verification that we have at least 2 gpus to run dist examples """
16 has_gpu = torch.accelerator.is_available()
17 gpu_count = torch.accelerator.device_count()
18 return has_gpu and gpu_count >= min_gpus
19
20class ToyModel(nn.Module):
21 def __init__(self):

Callers 1

example.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected