Skip to content
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

seed is not working #392

Open
shekhovt opened this issue Oct 18, 2024 · 0 comments
Open

seed is not working #392

shekhovt opened this issue Oct 18, 2024 · 0 comments

Comments

@shekhovt
Copy link

Hi,

I am failing to get reproducible behavior with the help of fixing the seed parameter. I've tried

num_workers = 0
batch_size = 10
batches_ahead = 1
torch.manual_seed(0)
np.random.seed(0)
train_loader = ffcv.loader.Loader(train_set, batch_size=batch_size, os_cache=True, batches_ahead=batches_ahead, num_workers=num_workers, order=OrderOption.QUASI_RANDOM, seed = o.data_seed, pipelines=train_pipelines(), drop_last=True)
(data,target) = next(iter(train_loader))
print(data.mean())
print(target)
del train_loader
torch.manual_seed(0)
np.random.seed(0)
train_loader = ffcv.loader.Loader(train_set, batch_size=batch_size, os_cache=True, batches_ahead=batches_ahead, num_workers=num_workers, order=OrderOption.QUASI_RANDOM, seed = o.data_seed, pipelines=train_pipelines(), drop_last=True)
(data,target) = next(iter(train_loader))
print(target)
print(data.mean())

It prints different results:

tensor(0.0761)
tensor(-0.0380)

I expect to get the same values. As far as I can tell, the problem is with RandomResizedCropRGBImageDecoder in the pipeline. I believe the original images selected in the batch are always the same and are in the same order. But it seems to me that the decoder gets applied in a multiprocessing setup, maybe not in the same order or not respecting the seed and as a result randomly crops differently each time. If I use e.g. CenterCropRGBImageDecoder and RandomHorizontalFlip, I get reproducible behavior.

Would it be possible to address this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant