mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-12-30 05:41:11 -08:00
send all three of GFPGAN's and codeformer's models to CPU memory instead of just one for #1283
This commit is contained in:
parent
556c36b960
commit
6c6ae28bf5
4 changed files with 41 additions and 11 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import contextlib
|
||||
|
||||
import torch
|
||||
|
||||
# has_mps is only available in nightly pytorch (for now), `getattr` for compatibility
|
||||
|
|
@ -57,3 +59,11 @@ def randn_without_seed(shape):
|
|||
|
||||
return torch.randn(shape, device=device)
|
||||
|
||||
|
||||
def autocast():
|
||||
from modules import shared
|
||||
|
||||
if dtype == torch.float32 or shared.cmd_opts.precision == "full":
|
||||
return contextlib.nullcontext()
|
||||
|
||||
return torch.autocast("cuda")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue