nerdyrodent / VQGAN-CLIP

Just playing with getting VQGAN+CLIP running locally, rather than having to use colab.
Other
2.59k stars 427 forks source link

setting seed doesn't guarantee reprudicibility #105

Open HitLuca opened 2 years ago

HitLuca commented 2 years ago

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

FaradaysInfinity commented 2 years ago

these lines, are they in the generate.py?

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

HitLuca commented 2 years ago

@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

ceathar commented 2 years ago

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.

HitLuca commented 2 years ago

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