send all three of GFPGAN's and codeformer's models to CPU memory instead of just one for #1283

This commit is contained in:
AUTOMATIC
2022-10-04 12:32:22 +03:00
parent 556c36b960
commit 6c6ae28bf5
4 changed files with 41 additions and 11 deletions

View File

@@ -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")