MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / enable_full_determinism

Function enable_full_determinism

src/diffusers/utils/testing_utils.py:804–819  ·  view source on GitHub ↗

Helper function for reproducible behavior during distributed training. See - https://pytorch.org/docs/stable/notes/randomness.html for pytorch

()

Source from the content-addressed store, hash-verified

802
803
804def 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
822def disable_full_determinism():

Calls

no outgoing calls

Tested by

no test coverage detected