Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,15 +7,24 @@ import spaces # Mandatory library for Hugging Face ZeroGPU [1]
|
|
| 7 |
|
| 8 |
MODEL_ID = "DevStudio-AI/Devstudio-Coder-1.5B"
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
print("Loading tokenizer and base model...")
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# We load the model in 16-bit on CPU first
|
| 14 |
# ZeroGPU will automatically move the model to the GPU when the decorated function runs [1]
|
| 15 |
model = AutoModelForCausalLM.from_pretrained(
|
| 16 |
MODEL_ID,
|
| 17 |
torch_dtype=torch.float16,
|
| 18 |
-
device_map="cpu"
|
|
|
|
| 19 |
)
|
| 20 |
print("Model successfully loaded on CPU. Awaiting ZeroGPU allocation...")
|
| 21 |
|
|
|
|
| 7 |
|
| 8 |
MODEL_ID = "DevStudio-AI/Devstudio-Coder-1.5B"
|
| 9 |
|
| 10 |
+
# Fetch your secure token from the Space Secrets environment
|
| 11 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 12 |
+
|
| 13 |
print("Loading tokenizer and base model...")
|
| 14 |
+
|
| 15 |
+
# Pass the token parameter to ensure complete, authenticated downloads
|
| 16 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 17 |
+
MODEL_ID,
|
| 18 |
+
token=HF_TOKEN
|
| 19 |
+
)
|
| 20 |
|
| 21 |
# We load the model in 16-bit on CPU first
|
| 22 |
# ZeroGPU will automatically move the model to the GPU when the decorated function runs [1]
|
| 23 |
model = AutoModelForCausalLM.from_pretrained(
|
| 24 |
MODEL_ID,
|
| 25 |
torch_dtype=torch.float16,
|
| 26 |
+
device_map="cpu",
|
| 27 |
+
token=HF_TOKEN
|
| 28 |
)
|
| 29 |
print("Model successfully loaded on CPU. Awaiting ZeroGPU allocation...")
|
| 30 |
|