(args)
| 204 | torch.save(*args, **kwargs) |
| 205 | |
| 206 | def init_distributed_mode(args): |
| 207 | if 'RANK' in os.environ and 'WORLD_SIZE' in os.environ: |
| 208 | args.rank = int(os.environ["RANK"]) |
| 209 | args.world_size = int(os.environ['WORLD_SIZE']) |
| 210 | args.gpu = int(os.environ['LOCAL_RANK']) |
| 211 | elif 'SLURM_PROCID' in os.environ: |
| 212 | args.rank = int(os.environ['SLURM_PROCID']) |
| 213 | args.gpu = args.rank % torch.cuda.device_count() |
| 214 | else: |
| 215 | print('Not using distributed mode') |
| 216 | args.distributed = False |
| 217 | return |
| 218 | |
| 219 | args.distributed = True |
| 220 | |
| 221 | torch.cuda.set_device(args.gpu) |
| 222 | args.dist_backend = 'nccl' |
| 223 | print('| distributed init (rank {}): {}'.format( |
| 224 | args.rank, args.dist_url), flush=True) |
| 225 | torch.distributed.init_process_group(backend=args.dist_backend, init_method=args.dist_url, |
| 226 | world_size=args.world_size, rank=args.rank) |
| 227 | torch.distributed.barrier() |
| 228 | setup_for_distributed(args.rank == 0) |
| 229 | |
| 230 | |
| 231 | def replace_batchnorm(net): |
nothing calls this directly
no test coverage detected