Download lib/train/admin/multigpu.py from AhmedLabib1/stark-full: direct link, hf CLI and curl.
- Browser
- Download file 467 Bytes
-
https://huggingface.co/AhmedLabib1/stark-full/resolve/main/lib/train/admin/multigpu.py
- Command line
-
hf download hf://AhmedLabib1/stark-full/lib/train/admin/multigpu.py
-
curl -L -o multigpu.py https://huggingface.co/AhmedLabib1/stark-full/resolve/main/lib/train/admin/multigpu.py
467 Bytes
| import torch.nn as nn | |
| # Here we use DistributedDataParallel(DDP) rather than DataParallel(DP) for multiple GPUs training | |
| def is_multi_gpu(net): | |
| return isinstance(net, (MultiGPU, nn.parallel.distributed.DistributedDataParallel)) | |
| class MultiGPU(nn.parallel.distributed.DistributedDataParallel): | |
| def __getattr__(self, item): | |
| try: | |
| return super().__getattr__(item) | |
| except: | |
| pass | |
| return getattr(self.module, item) | |