aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-04-29 08:16:06 +0000
committerGitHub <noreply@github.com>2023-04-29 08:16:06 +0000
commitcb9571e37fc1c0ee22c92ee726147f64ee80f07a (patch)
tree276c16e211146d0934c9aa330556545294b1a1ad /modules/devices.py
parent09069918e8e6e4e25a804d34c803abc3b76ae84a (diff)
parentd40e44ade479f7bba30d5317381cbc58c861775b (diff)
downloadstable-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.py8
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)