Spaces:
Sleeping
Sleeping
afnotes commited on
Commit ·
ebb8aa3
1
Parent(s): 8170a49
Edited app.py again :(
Browse files
app.py
CHANGED
|
@@ -1,9 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 4 |
from peft import PeftModel
|
| 5 |
import os
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# --- Configuration ---
|
| 8 |
BASE_MODEL_ID = "Qwen/Qwen3-4B"
|
| 9 |
ADAPTER_MODEL_ID = "afnotes/Qwen3-4B-YeI-LoRA"
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 4 |
from peft import PeftModel
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
# Add this GPU check here
|
| 8 |
+
if not torch.cuda.is_available():
|
| 9 |
+
# If CUDA is not available, try to explain and possibly fall back to CPU if memory allows (unlikely for 4B)
|
| 10 |
+
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
| 11 |
+
print("WARNING: CUDA (GPU) is NOT available on this Space instance.")
|
| 12 |
+
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
| 13 |
+
# You might consider removing the quantization_config and trying CPU, but for 4B it will likely crash
|
| 14 |
+
# For now, we'll let it fail if it can't find a GPU as intended.
|
| 15 |
+
else:
|
| 16 |
+
print(f"CUDA is available! PyTorch detected GPU: {torch.cuda.get_device_name(0)}")
|
| 17 |
+
|
| 18 |
# --- Configuration ---
|
| 19 |
BASE_MODEL_ID = "Qwen/Qwen3-4B"
|
| 20 |
ADAPTER_MODEL_ID = "afnotes/Qwen3-4B-YeI-LoRA"
|