Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions optimizedSD/optimized_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def load_img(path, h0, w0):
init_latent = modelFS.get_first_stage_encoding(modelFS.encode_first_stage(init_image)) # move to latent space

if opt.device != "cpu":
mem = torch.cuda.memory_allocated() / 1e6
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
modelFS.to("cpu")
while torch.cuda.memory_allocated() / 1e6 >= mem:
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
time.sleep(1)


Expand Down Expand Up @@ -302,9 +302,9 @@ def load_img(path, h0, w0):
c = modelCS.get_learned_conditioning(prompts)

if opt.device != "cpu":
mem = torch.cuda.memory_allocated() / 1e6
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
modelCS.to("cpu")
while torch.cuda.memory_allocated() / 1e6 >= mem:
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
time.sleep(1)

# encode (scaled latent)
Expand Down Expand Up @@ -340,13 +340,13 @@ def load_img(path, h0, w0):
base_count += 1

if opt.device != "cpu":
mem = torch.cuda.memory_allocated() / 1e6
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
modelFS.to("cpu")
while torch.cuda.memory_allocated() / 1e6 >= mem:
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
time.sleep(1)

del samples_ddim
print("memory_final = ", torch.cuda.memory_allocated() / 1e6)
print("memory_final = ", torch.cuda.memory_allocated(device=opt.device) / 1e6)

toc = time.time()

Expand Down