PyTorch torch.set_deterministic_debug_mode Function


Pytorch torch Reference Manual

torch.set_deterministic_debug_modeThis function is used to set the deterministic debug mode in PyTorch. When set to a non-zero value, PyTorch will throw an error or warning when a non-deterministic algorithm is used.

Function Definition

torch.set_deterministic_debug_mode(debug_mode)

Parameter Description

  • debug_mode: Debug mode, optional values:
    • 0: Off (default)
    • 1: Enable strict mode
    • 2: Enable warning mode

Usage Example

Example

import torch

# Set the deterministic debug mode to strict mode
# This will throw an error when non-deterministic 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)

print("Deterministic debug mode has been set")

The output is:

Deterministic debug mode has been set

Pytorch torch Reference Manual

Other Extensions