Skip to content

Commit 7ecf962

Browse files
author
Kieran Liu
committed
fixing bugs that using gpus other than cuda:0
1 parent 332f34c commit 7ecf962

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

optimizedSD/optimized_img2img.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ def load_img(path, h0, w0):
253253
init_latent = modelFS.get_first_stage_encoding(modelFS.encode_first_stage(init_image)) # move to latent space
254254

255255
if opt.device != "cpu":
256-
mem = torch.cuda.memory_allocated() / 1e6
256+
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
257257
modelFS.to("cpu")
258-
while torch.cuda.memory_allocated() / 1e6 >= mem:
258+
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
259259
time.sleep(1)
260260

261261

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

304304
if opt.device != "cpu":
305-
mem = torch.cuda.memory_allocated() / 1e6
305+
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
306306
modelCS.to("cpu")
307-
while torch.cuda.memory_allocated() / 1e6 >= mem:
307+
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
308308
time.sleep(1)
309309

310310
# encode (scaled latent)
@@ -340,13 +340,13 @@ def load_img(path, h0, w0):
340340
base_count += 1
341341

342342
if opt.device != "cpu":
343-
mem = torch.cuda.memory_allocated() / 1e6
343+
mem = torch.cuda.memory_allocated(device=opt.device) / 1e6
344344
modelFS.to("cpu")
345-
while torch.cuda.memory_allocated() / 1e6 >= mem:
345+
while torch.cuda.memory_allocated(device=opt.device) / 1e6 >= mem:
346346
time.sleep(1)
347347

348348
del samples_ddim
349-
print("memory_final = ", torch.cuda.memory_allocated() / 1e6)
349+
print("memory_final = ", torch.cuda.memory_allocated(device=opt.device) / 1e6)
350350

351351
toc = time.time()
352352

0 commit comments

Comments
 (0)