Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -96,7 +96,12 @@ def load_model():
|
|
| 96 |
hf_hub_download(ADAPTER_REPO, f"{ADAPTER_SUBFOLDER}/{fname}")
|
| 97 |
adapter_dir = Path(hf_hub_download(
|
| 98 |
ADAPTER_REPO, f"{ADAPTER_SUBFOLDER}/adapter_config.json")).parent
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
model.eval()
|
| 101 |
return model
|
| 102 |
|
|
|
|
| 96 |
hf_hub_download(ADAPTER_REPO, f"{ADAPTER_SUBFOLDER}/{fname}")
|
| 97 |
adapter_dir = Path(hf_hub_download(
|
| 98 |
ADAPTER_REPO, f"{ADAPTER_SUBFOLDER}/adapter_config.json")).parent
|
| 99 |
+
# torch_device="cpu": peft otherwise infers "cuda" and safetensors tries to
|
| 100 |
+
# open the file straight onto the (ZeroGPU-virtual) GPU at import time,
|
| 101 |
+
# which dies with "No CUDA GPUs are available" in the main process.
|
| 102 |
+
# Loading on CPU here is free — .to("cuda") below moves everything.
|
| 103 |
+
model = PeftModel.from_pretrained(base, str(adapter_dir),
|
| 104 |
+
torch_device="cpu")
|
| 105 |
model.eval()
|
| 106 |
return model
|
| 107 |
|