diff options
author | Deciare <1689220+deciare@users.noreply.github.com> | 2023-04-19 03:18:58 +0000 |
---|---|---|
committer | Deciare <1689220+deciare@users.noreply.github.comw> | 2023-04-19 03:27:46 +0000 |
commit | d40e44ade479f7bba30d5317381cbc58c861775b (patch) | |
tree | 40755c59268f844ba1aa8f0dcec8cf5fdb66699a /modules/devices.py | |
parent | 22bcc7be428c94e9408f589966c2040187245d81 (diff) | |
download | stable-diffusion-webui-gfx803-d40e44ade479f7bba30d5317381cbc58c861775b.tar.gz stable-diffusion-webui-gfx803-d40e44ade479f7bba30d5317381cbc58c861775b.tar.bz2 stable-diffusion-webui-gfx803-d40e44ade479f7bba30d5317381cbc58c861775b.zip |
Option to use CPU for random number generation.
Makes a given manual seed generate the same images across different
platforms, independently of the GPU architecture in use.
Fixes #9613.
Diffstat (limited to 'modules/devices.py')
-rw-r--r-- | modules/devices.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/devices.py b/modules/devices.py index 52c3e7cd..3bc86a6a 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -92,14 +92,18 @@ def cond_cast_float(input): def randn(seed, shape): + from modules.shared import opts + torch.manual_seed(seed) - if device.type == 'mps': + if opts.use_cpu_randn or device.type == 'mps': return torch.randn(shape, device=cpu).to(device) return torch.randn(shape, device=device) def randn_without_seed(shape): - if device.type == 'mps': + from modules.shared import opts + + if opts.use_cpu_randn or device.type == 'mps': return torch.randn(shape, device=cpu).to(device) return torch.randn(shape, device=device) |