prevent 'torch' has no attribute 'cuda' error in torch_gc, so user can use CPU or WebGPU (#302)
This commit is contained in:
parent
dd89041f72
commit
bb1a6191b0
@ -19,9 +19,12 @@ def set_torch():
|
||||
|
||||
|
||||
def torch_gc():
|
||||
try:
|
||||
import torch
|
||||
|
||||
if torch.cuda.is_available():
|
||||
with torch.cuda.device(0):
|
||||
torch.cuda.empty_cache()
|
||||
torch.cuda.ipc_collect()
|
||||
except:
|
||||
pass # prevent 'torch' has no attribute 'cuda' error, so user can use CPU or WebGPU
|
||||
|
Loading…
Reference in New Issue
Block a user