Spaces:
Runtime error
Runtime error
GPU enabled
Browse files- README.md +8 -5
- app.py +7 -2
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -7,12 +7,12 @@ sdk: gradio
|
|
| 7 |
sdk_version: 6.5.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
suggested_hardware:
|
| 11 |
license: artistic-2.0
|
| 12 |
short_description: CPU-only local Nemotron GGUF chat
|
| 13 |
---
|
| 14 |
|
| 15 |
-
Dreadzone is a
|
| 16 |
`llama-cpp-python` and Gradio ChatInterface.
|
| 17 |
|
| 18 |
The app downloads
|
|
@@ -21,16 +21,18 @@ automatically on first launch and streams responses from
|
|
| 21 |
`NVIDIA-Nemotron-3-Nano-4B-Q5_K_M.gguf`.
|
| 22 |
|
| 23 |
No hosted inference API, OAuth token, secrets, or external inference services are
|
| 24 |
-
used.
|
|
|
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
The defaults are intentionally conservative
|
| 29 |
|
| 30 |
- `N_CTX=2048`
|
| 31 |
- `N_BATCH=128`
|
| 32 |
- `MAX_HISTORY_TURNS=6`
|
| 33 |
- `N_THREADS` defaults to one fewer than the detected CPU count
|
|
|
|
| 34 |
|
| 35 |
You can override the model or runtime settings with Space variables:
|
| 36 |
|
|
@@ -40,4 +42,5 @@ You can override the model or runtime settings with Space variables:
|
|
| 40 |
- `N_CTX`
|
| 41 |
- `N_BATCH`
|
| 42 |
- `N_THREADS`
|
|
|
|
| 43 |
- `MAX_HISTORY_TURNS`
|
|
|
|
| 7 |
sdk_version: 6.5.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
suggested_hardware: t4-small
|
| 11 |
license: artistic-2.0
|
| 12 |
short_description: CPU-only local Nemotron GGUF chat
|
| 13 |
---
|
| 14 |
|
| 15 |
+
Dreadzone is a Hugging Face Space that runs a local GGUF model with
|
| 16 |
`llama-cpp-python` and Gradio ChatInterface.
|
| 17 |
|
| 18 |
The app downloads
|
|
|
|
| 21 |
`NVIDIA-Nemotron-3-Nano-4B-Q5_K_M.gguf`.
|
| 22 |
|
| 23 |
No hosted inference API, OAuth token, secrets, or external inference services are
|
| 24 |
+
used. The default dependency pin uses the CUDA 12.4 `llama-cpp-python` wheel for
|
| 25 |
+
GPU Spaces.
|
| 26 |
|
| 27 |
+
## Runtime settings
|
| 28 |
|
| 29 |
+
The defaults are intentionally conservative while enabling GPU offload:
|
| 30 |
|
| 31 |
- `N_CTX=2048`
|
| 32 |
- `N_BATCH=128`
|
| 33 |
- `MAX_HISTORY_TURNS=6`
|
| 34 |
- `N_THREADS` defaults to one fewer than the detected CPU count
|
| 35 |
+
- `N_GPU_LAYERS=-1` offloads all possible layers to GPU
|
| 36 |
|
| 37 |
You can override the model or runtime settings with Space variables:
|
| 38 |
|
|
|
|
| 42 |
- `N_CTX`
|
| 43 |
- `N_BATCH`
|
| 44 |
- `N_THREADS`
|
| 45 |
+
- `N_GPU_LAYERS`
|
| 46 |
- `MAX_HISTORY_TURNS`
|
app.py
CHANGED
|
@@ -13,6 +13,7 @@ MODEL_FILE = os.getenv("MODEL_FILE", "NVIDIA-Nemotron-3-Nano-4B-Q5_K_M.gguf")
|
|
| 13 |
N_CTX = int(os.getenv("N_CTX", "2048"))
|
| 14 |
N_BATCH = int(os.getenv("N_BATCH", "128"))
|
| 15 |
N_THREADS = int(os.getenv("N_THREADS", str(max(1, (os.cpu_count() or 2) - 1))))
|
|
|
|
| 16 |
MAX_HISTORY_TURNS = int(os.getenv("MAX_HISTORY_TURNS", "6"))
|
| 17 |
|
| 18 |
DEFAULT_SYSTEM_PROMPT = (
|
|
@@ -23,7 +24,11 @@ DEFAULT_SYSTEM_PROMPT = (
|
|
| 23 |
|
| 24 |
@lru_cache(maxsize=1)
|
| 25 |
def get_llm() -> Llama:
|
| 26 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 28 |
print(f"Model file ready: {model_path}", flush=True)
|
| 29 |
|
|
@@ -32,7 +37,7 @@ def get_llm() -> Llama:
|
|
| 32 |
n_ctx=N_CTX,
|
| 33 |
n_batch=N_BATCH,
|
| 34 |
n_threads=N_THREADS,
|
| 35 |
-
n_gpu_layers=
|
| 36 |
use_mmap=True,
|
| 37 |
use_mlock=False,
|
| 38 |
logits_all=False,
|
|
|
|
| 13 |
N_CTX = int(os.getenv("N_CTX", "2048"))
|
| 14 |
N_BATCH = int(os.getenv("N_BATCH", "128"))
|
| 15 |
N_THREADS = int(os.getenv("N_THREADS", str(max(1, (os.cpu_count() or 2) - 1))))
|
| 16 |
+
N_GPU_LAYERS = int(os.getenv("N_GPU_LAYERS", "-1"))
|
| 17 |
MAX_HISTORY_TURNS = int(os.getenv("MAX_HISTORY_TURNS", "6"))
|
| 18 |
|
| 19 |
DEFAULT_SYSTEM_PROMPT = (
|
|
|
|
| 24 |
|
| 25 |
@lru_cache(maxsize=1)
|
| 26 |
def get_llm() -> Llama:
|
| 27 |
+
print(
|
| 28 |
+
f"Loading model {MODEL_REPO}/{MODEL_FILE} "
|
| 29 |
+
f"with n_gpu_layers={N_GPU_LAYERS}",
|
| 30 |
+
flush=True,
|
| 31 |
+
)
|
| 32 |
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
|
| 33 |
print(f"Model file ready: {model_path}", flush=True)
|
| 34 |
|
|
|
|
| 37 |
n_ctx=N_CTX,
|
| 38 |
n_batch=N_BATCH,
|
| 39 |
n_threads=N_THREADS,
|
| 40 |
+
n_gpu_layers=N_GPU_LAYERS,
|
| 41 |
use_mmap=True,
|
| 42 |
use_mlock=False,
|
| 43 |
logits_all=False,
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/
|
| 2 |
|
| 3 |
gradio==6.5.1
|
| 4 |
huggingface_hub>=0.23.0
|
|
|
|
| 1 |
+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124
|
| 2 |
|
| 3 |
gradio==6.5.1
|
| 4 |
huggingface_hub>=0.23.0
|