PyTorch torch.set_deterministic_debug_mode function
PyTorch torch reference manual
torch.set_deterministic_debug_mode is a function in PyTorch used to set the deterministic debug mode. When set to a nonzero value, PyTorch raises an error or warning when nondeterministic algorithms are used.
Function definition
torch.set_deterministic_debug_mode(debug_mode)
Parameter Description
debug_mode: debug mode, optional values:0: off (default)1: enable strict mode2: enable warning mode
Usage examples
Example
import
torch
Set the deterministic debug mode to strict
This raises an error when nondeterministic operations are used
torch.
set_deterministic_debug_mode
(
1
)
Set to warning mode
torch.
set_deterministic_debug_mode
(
2
)
Turn off debug mode
torch.
set_deterministic_debug_mode
(
0
)
(
"Deterministic debug mode set"
)
The output is:
确定性调试模式已设置