Allow for warn_only selection in enable_full_determinism (#24496)

* Warn only in enable full determinism

* Add option in the function definition
This commit is contained in:
Frank995 2023-06-28 14:54:36 +02:00 committed by GitHub
parent 11cb6e0f7e
commit daccde143d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,7 @@ def seed_worker(_):
set_seed(worker_seed)
def enable_full_determinism(seed: int):
def enable_full_determinism(seed: int, warn_only: bool = False):
"""
Helper function for reproducible behavior during distributed training. See
- https://pytorch.org/docs/stable/notes/randomness.html for pytorch
@ -70,7 +70,7 @@ def enable_full_determinism(seed: int):
# depending on the CUDA version, so we set them both here
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
torch.use_deterministic_algorithms(True)
torch.use_deterministic_algorithms(True, warn_only=warn_only)
# Enable CUDNN deterministic mode
torch.backends.cudnn.deterministic = True