diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 08:16:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 08:16:06 +0000 |
commit | cb9571e37fc1c0ee22c92ee726147f64ee80f07a (patch) | |
tree | 276c16e211146d0934c9aa330556545294b1a1ad /modules/devices.py | |
parent | 09069918e8e6e4e25a804d34c803abc3b76ae84a (diff) | |
parent | d40e44ade479f7bba30d5317381cbc58c861775b (diff) | |
download | stable-diffusion-webui-gfx803-cb9571e37fc1c0ee22c92ee726147f64ee80f07a.tar.gz stable-diffusion-webui-gfx803-cb9571e37fc1c0ee22c92ee726147f64ee80f07a.tar.bz2 stable-diffusion-webui-gfx803-cb9571e37fc1c0ee22c92ee726147f64ee80f07a.zip |
Merge pull request #9734 from deciare/cpu-randn
Option to make images generated from a given manual seed consistent across CUDA and MPS devices
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) |