Helper function for reproducible behavior during distributed training. See - https://pytorch.org/docs/stable/notes/randomness.html for pytorch
()
| 802 | |
| 803 | |
| 804 | def enable_full_determinism(): |
| 805 | """ |
| 806 | Helper function for reproducible behavior during distributed training. See |
| 807 | - https://pytorch.org/docs/stable/notes/randomness.html for pytorch |
| 808 | """ |
| 809 | # Enable PyTorch deterministic mode. This potentially requires either the environment |
| 810 | # variable 'CUDA_LAUNCH_BLOCKING' or 'CUBLAS_WORKSPACE_CONFIG' to be set, |
| 811 | # depending on the CUDA version, so we set them both here |
| 812 | os.environ["CUDA_LAUNCH_BLOCKING"] = "1" |
| 813 | os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8" |
| 814 | torch.use_deterministic_algorithms(True) |
| 815 | |
| 816 | # Enable CUDNN deterministic mode |
| 817 | torch.backends.cudnn.deterministic = True |
| 818 | torch.backends.cudnn.benchmark = False |
| 819 | torch.backends.cuda.matmul.allow_tf32 = False |
| 820 | |
| 821 | |
| 822 | def disable_full_determinism(): |
no outgoing calls
no test coverage detected