-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting inference seed is nowhere to be found in the doc #4272
Comments
Try to use follow import torch
import numpy as np
import random
def fix_seed(identical_seed : int = 1024):
torch.manual_seed(identical_seed)
torch.cuda.manual_seed(identical_seed)
torch.cuda.manual_seed_all(identical_seed)
np.random.seed(identical_seed)
random.seed(identical_seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False |
@lix19937 , thank you for your help. However this does not work, I tested it today. import pycuda.autoinit
from pycuda import curandom
import numpy as np
import pycuda
def seed_getter(N):
array = np.array([42]*N).astype(np.int32)
array = pycuda.gpuarray.to_gpu(array)
return array
sampler = curandom.XORWOWRandomNumberGenerator(seed_getter=seed_getter)
print(sampler.gen_uniform(1000, np.float32).get()[0])
sampler = curandom.XORWOWRandomNumberGenerator(seed_getter=seed_getter)
print(sampler.gen_uniform(1000, np.float32).get()[0]) |
@londumas Why do you not use the fixed inputs ? |
@londumas if your model contains random ops that require a seed input, TensorRT doesn't support specifying this input at the moment. We may add support in the future. However, in the event that the input to your model is a randomly generated tensor, you can set the seed during input tensor initialization in PyTorch. |
I have exported a SegNext-t to .engine, and I infer images with it. The issue is that this model is not deterministic since it uses matrix decomposition through random numbers. One simple way to do so in onnxruntime is trhough
ort.set_seed(seed)
. However I can not find anywhere how to do the same for tensorrt in python. I do not find anything in the documentation about reproductibility.The text was updated successfully, but these errors were encountered: