Helper function for reproducible behavior during distributed training. See - https://pytorch.org/docs/stable/notes/randomness.html for pytorch
()
| 562 | |
| 563 | |
| 564 | def enable_full_determinism(): |
| 565 | """ |
| 566 | Helper function for reproducible behavior during distributed training. See |
| 567 | - https://pytorch.org/docs/stable/notes/randomness.html for pytorch |
| 568 | """ |
| 569 | # Enable PyTorch deterministic mode. This potentially requires either the environment |
| 570 | # variable 'CUDA_LAUNCH_BLOCKING' or 'CUBLAS_WORKSPACE_CONFIG' to be set, |
| 571 | # depending on the CUDA version, so we set them both here |
| 572 | os.environ["CUDA_LAUNCH_BLOCKING"] = "1" |
| 573 | os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8" |
| 574 | torch.use_deterministic_algorithms(True) |
| 575 | |
| 576 | # Enable CUDNN deterministic mode |
| 577 | torch.backends.cudnn.deterministic = True |
| 578 | torch.backends.cudnn.benchmark = False |
| 579 | torch.backends.cuda.matmul.allow_tf32 = False |
nothing calls this directly
no outgoing calls
no test coverage detected