()
| 42 | |
| 43 | |
| 44 | def init_distributed_mode(): |
| 45 | if int(os.environ.get("RANK", -1)) == -1: |
| 46 | return 0 # 非DDP模式 |
| 47 | |
| 48 | dist.init_process_group(backend="nccl") |
| 49 | local_rank = int(os.environ["LOCAL_RANK"]) |
| 50 | torch.cuda.set_device(local_rank) |
| 51 | return local_rank |
| 52 | |
| 53 | |
| 54 | def setup_seed(seed: int): |
no outgoing calls
no test coverage detected