The fight against non-deterministic results #9371
Replies: 7 comments 5 replies
-
I didn't disable benchmarks, but have never seen an example on a local device where a reboot would change things, and even if I reproduce the results now, they are 100% the same. I feel that A) may still have a small amount of variance. PyTorch does not guarantee consistency in different environments. The documentation only shows the means to reduce uncertainty, and your resistance may be in vain. Maybe you can try to compare the results in CPU mode by running locally and on cloud services (such as colab). |
Beta Was this translation helpful? Give feedback.
-
Maybe we could run a test, several people state their settings and hardware and run the same prompt in the same model, etc, and post the result? Or someone could create an extension for that, like the one that does benchmarks and collects the info. |
Beta Was this translation helpful? Give feedback.
-
here are some tests.
So it appears it's really just a hardware thing. Sadly, as I get somewhat of a style shift, as mentioned above. And that's the biggest problem I see. After a 500 batch, that what clearly noticeable in most of the pictures. Not a single one looked as good as it does when I work with the RTX 2080. -* Initial noise has been done via cpu by modifying devices.py. I was hoping this gives a more stable, less different result, but unfortunately it does not. And since the "starting shot" comes from the cpu, it's very seed braking. Guess I try to get another 2nd rtx 2080 -.- |
Beta Was this translation helpful? Give feedback.
-
Having results be worse (and not just different) suggests something more than just different PRNG in the noise, right? If you tried generating the noise on the CPU and it's still different, does that point to something other than noise entirely? (Just throwing darts, it's probably hard to get help on this since most people don't have multiple GPUs to compare...) |
Beta Was this translation helpful? Give feedback.
-
Also, you should post the resulting images in png, and the prompt and settings you used, so others can try and compare. |
Beta Was this translation helpful? Give feedback.
-
Xformers 0.0.19 is said to be deterministic, and indeed in the same session I get the same result when regenerating the same prompt. But when I close and restart SD, I get the usual slightly divergent result, although once more constant for the duration of the session. |
Beta Was this translation helpful? Give feedback.
-
I've seen more deterministic results on my setup by enabling |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, hello community.
I'm aware that several commandline args (such as xformers) cause non-deterministic behaviours.
What is most likely less common knowledge is for example the torch.backends.cudnn.benchmark flag in devices.py, as it might cause non-deterministic behavoir across sessions (relaunching the WebUI) (see doc here https://pytorch.org/docs/stable/notes/randomness.html)
I must not, but may give different results after relaunching (could confirm it in 10/10 cases, with flag = true and false)
Now for the more important part, GPU. That is the biggest problem in my opinion. The results I get from a rtx 3060Ti extremely far away from the ones on rtx 2080 Super. And I can't affort to buy tons of machines just to see wich gives me close results.
If I get it right, the GPU, wich creates the noise in response to the give seed. Given the same seed a 2nd, without having anything changed at all, would produce the exact same noise, resulting lastly, in a 100% identical output.
Now a different GPU, has the same behaviour, but produces different noise for the very same seed. Kinda similar to different search engines, same input, different output, more or less.
Now I wonder about following
A) what would happen if I have 2 different machines, but both of em having the examt same GPU, drivers and CUDA kids (and OS)
B) the information on the pytorch doc, and these lines in 'progressing.py':
# randn results depend on device; gpu and cpu get different results for same seed;
# the way I see it, it's better to do this on CPU, so that everyone gets same result;
# but the original script had it like this, so I do not dare change it for now because
# it will break everyone's seeds.
noise = devices.randn(seed, noise_shape)
lead me to the idea, that it could be eventually done via a offset??? (i think that is what people doing using ensd without knowing, event though it doesn't change anything for me when change ensd)
C) anyone tried on 2 different CPU's ?
Beta Was this translation helpful? Give feedback.
All reactions