VQGAN-CLIP icon indicating copy to clipboard operation
VQGAN-CLIP copied to clipboard

setting seed doesn't guarantee reprudicibility

Open HitLuca opened this issue 3 years ago • 4 comments

Looks like setting the seed doesn't truly produce the same results. After some testing I noticed that these lines

        torch.manual_seed(seed)
        torch.backends.cudnn.benchmark = False

should be improved by adding the following statements

        torch.manual_seed(seed)
        torch.cuda.manual_seed(seed)
        torch.cuda.manual_seed_all(seed)
        np.random.seed(seed)
        random.seed(seed)
        torch.backends.cudnn.benchmark = False
        torch.backends.cudnn.deterministic = True

If this is not the case then I may have modified some files when checking out this project and removed determinism

HitLuca avatar Dec 20 '21 14:12 HitLuca

these lines, are they in the generate.py?

i have found the same but cannot find where to add your code in

FaradaysInfinity avatar Jan 04 '22 09:01 FaradaysInfinity

@FaradaysInfinity you can add the seed-related lines here, and the cudnn-related lines here. I rewritten most of this project from scratch, so I have everything in the same place but it shouldn't matter

HitLuca avatar Jan 04 '22 09:01 HitLuca

hi, did you find any other parameters needed to assure reproducibility? I have implemented the lines your mention, and I get very close results, but not exactly the same.

ceathar avatar Mar 07 '22 10:03 ceathar

The weird thing is that even after searching online I couldn't figure out what other randomness source could be at play here

HitLuca avatar Mar 09 '22 08:03 HitLuca