Spaces:
Running on Zero
Running on Zero
File size: 448 Bytes
5c93746 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | """Small runtime helpers used by the offline and online inference entrypoints."""
import random
import numpy as np
import torch
def set_seed(seed: int, deterministic: bool = False) -> None:
"""Seed Python, NumPy, and PyTorch for reproducible inference."""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
if deterministic:
torch.use_deterministic_algorithms(True)
|