Spaces:
Running on Zero

Ruurd commited on
Commit
2b0f952
·
1 Parent(s): 617b180

Run on GPU if available, otherwise CPU

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -33,7 +33,8 @@ def load_model():
33
  token=os.getenv("HF_TOKEN")
34
  )
35
 
36
- model = torch.load(ckpt_path, map_location="cuda") # no weights_only, no globals hack
 
37
  model = disable_dropout(model)
38
  model.to("cuda")
39
  model.eval()
 
33
  token=os.getenv("HF_TOKEN")
34
  )
35
 
36
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
37
+ model = torch.load(ckpt_path, map_location=device)
38
  model = disable_dropout(model)
39
  model.to("cuda")
40
  model.eval()