Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
21effd62
Commit
21effd62
authored
Nov 28, 2022
by
brkirch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add workaround for using MPS with torchsde
parent
98ca437e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
modules/sd_samplers.py
modules/sd_samplers.py
+14
-0
No files found.
modules/sd_samplers.py
View file @
21effd62
...
...
@@ -6,6 +6,7 @@ import tqdm
from
PIL
import
Image
import
inspect
import
k_diffusion.sampling
import
torchsde._brownian.brownian_interval
import
ldm.models.diffusion.ddim
import
ldm.models.diffusion.plms
from
modules
import
prompt_parser
,
devices
,
processing
,
images
...
...
@@ -367,6 +368,19 @@ class TorchHijack:
return
torch
.
randn_like
(
x
)
# MPS fix for randn in torchsde
def
torchsde_randn
(
size
,
dtype
,
device
,
seed
):
if
device
.
type
==
'mps'
:
generator
=
torch
.
Generator
(
devices
.
cpu
)
.
manual_seed
(
int
(
seed
))
return
torch
.
randn
(
size
,
dtype
=
dtype
,
device
=
devices
.
cpu
,
generator
=
generator
)
.
to
(
device
)
else
:
generator
=
torch
.
Generator
(
device
)
.
manual_seed
(
int
(
seed
))
return
torch
.
randn
(
size
,
dtype
=
dtype
,
device
=
device
,
generator
=
generator
)
torchsde
.
_brownian
.
brownian_interval
.
_randn
=
torchsde_randn
class
KDiffusionSampler
:
def
__init__
(
self
,
funcname
,
sd_model
):
denoiser
=
k_diffusion
.
external
.
CompVisVDenoiser
if
sd_model
.
parameterization
==
"v"
else
k_diffusion
.
external
.
CompVisDenoiser
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment