Unverified Commit 997ac570 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #5095 from mlmcgoogan/master

torch.cuda.empty_cache() defaults to cuda:0 device unless explicitly …
parents d860b56c c67c40f9
...@@ -44,8 +44,18 @@ def get_optimal_device(): ...@@ -44,8 +44,18 @@ def get_optimal_device():
def torch_gc(): def torch_gc():
if torch.cuda.is_available(): if torch.cuda.is_available():
torch.cuda.empty_cache() from modules import shared
torch.cuda.ipc_collect()
device_id = shared.cmd_opts.device_id
if device_id is not None:
cuda_device = f"cuda:{device_id}"
else:
cuda_device = "cuda"
with torch.cuda.device(cuda_device):
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
def enable_tf32(): def enable_tf32():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment