Spaces:
Running on Zero
Running on Zero
GUI-Decisions Space
Browse files- slotread/local.py +3 -1
slotread/local.py
CHANGED
|
@@ -50,7 +50,9 @@ class LocalSlotModel:
|
|
| 50 |
attn_implementation="sdpa")
|
| 51 |
if adapter:
|
| 52 |
from peft import PeftModel
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
model.eval()
|
| 55 |
cfg = json.load(open(config)) if config else _config(adapter or model_id)
|
| 56 |
return cls(model, AutoProcessor.from_pretrained(processor or model_id), cfg)
|
|
|
|
| 50 |
attn_implementation="sdpa")
|
| 51 |
if adapter:
|
| 52 |
from peft import PeftModel
|
| 53 |
+
# on the model's device: under ZeroGPU CUDA looks available before a GPU is attached
|
| 54 |
+
kw = {"torch_device": "cpu"} if device_map == "cpu" else {}
|
| 55 |
+
model = PeftModel.from_pretrained(model, adapter, **kw)
|
| 56 |
model.eval()
|
| 57 |
cfg = json.load(open(config)) if config else _config(adapter or model_id)
|
| 58 |
return cls(model, AutoProcessor.from_pretrained(processor or model_id), cfg)
|