Run Hermes Agent with local Gemma 4 and llama.cpp on NVIDIA DGX Spark
Introduction
Explore the local agent architecture on DGX Spark
Build llama.cpp from source for NVIDIA DGX Spark
Download and benchmark Gemma 4 models on DGX Spark
Serve Gemma 4 E4B with a 64K context window
Install and configure Nous Research Hermes Agent
Validate Hermes Agent code fixing on NVIDIA DGX Spark
Next Steps
Run Hermes Agent with local Gemma 4 and llama.cpp on NVIDIA DGX Spark
Introduction
Explore the local agent architecture on DGX Spark
Build llama.cpp from source for NVIDIA DGX Spark
Download and benchmark Gemma 4 models on DGX Spark
Serve Gemma 4 E4B with a 64K context window
Install and configure Nous Research Hermes Agent
Validate Hermes Agent code fixing on NVIDIA DGX Spark
Next Steps
Create a local test workspace
You’ll create a small test directory containing a Python script with two deliberate bugs. You’ll use the script to evaluate the end-to-end tool-calling loop of the Hermes Agent in a repeatable way.
Create the test directory:
mkdir -p ~/hermes-test-workspace
cd ~/hermes-test-workspace
Create metrics_parser.py with an intentional off-by-one divisor bug and a mismatched dictionary key name:
cat <<'EOF' > ~/hermes-test-workspace/metrics_parser.py
def average_latency(records):
if not records:
return 0.0
total = sum(r["latency"] for r in records)
return total / (len(records) - 1)
if __name__ == "__main__":
sample = [
{"endpoint": "/v1/models", "latency_ms": 12.0},
{"endpoint": "/v1/chat/completions", "latency_ms": 48.0},
]
print(f"Average latency: {average_latency(sample):.2f} ms")
EOF
Running the script reveals the KeyError: 'latency' failure, alongside the division by len(records) - 1 that skews averages and fails on single-item lists:
python3 metrics_parser.py
The output is similar to:
Traceback (most recent call last):
File "/home/user/hermes-test-workspace/metrics_parser.py", line 12, in <module>
print(f"Average latency: {average_latency(sample):.2f} ms")
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/hermes-test-workspace/metrics_parser.py", line 4, in average_latency
total = sum(r["latency"] for r in records)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/hermes-test-workspace/metrics_parser.py", line 4, in <genexpr>
total = sum(r["latency"] for r in records)
~^^^^^^^^^^^
KeyError: 'latency'
Run the multi-step agent prompt
Run Hermes Agent inside ~/hermes-test-workspace with Gemma 4 E4B active on llama-server. You can run interactively with hermes or pass the prompt directly with hermes chat --cli:
hermes chat --cli -q "Inspect the current directory, read metrics_parser.py, diagnose any bugs, fix metrics_parser.py, and run python3 metrics_parser.py to verify the output." --oneshot
On the first turn of a new session, Hermes Agent sends an ~11K-token system prompt and tool schemas. With Blackwell GB10 GPU offloading active (~7,460 tok/s prefill with q8_0 key-value (KV) cache), cold prefill finishes in ~2–3 seconds. Subsequent tool calls reuse the llama-server KV cache.
Observe how the agent runs the full tool loop:
- Lists the workspace files and reads
metrics_parser.py. - Diagnoses both the
r["latency"]key mismatch and thelen(records) - 1divisor bug. - Patches both lines in
metrics_parser.py. - Runs
python3 metrics_parser.pyand confirmsAverage latency: 30.00 ms.
The output is similar to:
Query: Inspect the current directory, read metrics_parser.py, diagnose any bugs,
fix metrics_parser.py, and run python3 metrics_parser.py to verify the output.
...
💻 $ ls -R 0.2s
📖 Read metrics_parser.py
...
🔧 Patch metrics_parser.py
│ metrics_parser.py
│ @@ -1,8 +1,8 @@
│ def average_latency(records):
│ if not records:
│ return 0.0
│ - total = sum(r["latency"] for r in records)
│ - return total / (len(records) - 1)
│ + total = sum(r["latency_ms"] for r in records)
│ + return total / len(records)
│
│ if __name__ == "__main__":
│ sample = [
💻 $ python3 metrics_parser.py
────────────────────────────────────────
☤ Hermes
The directory inspection showed only metrics_parser.py. Analysis of the file identified two bugs:
1. KeyError: The function accessed r["latency"], but the sample data provided r["latency_ms"].
2. Incorrect average calculation: The function divided by len(records) - 1 instead of len(records).
The function was updated to use the correct key and calculate the mean correctly.
Execution of python3 metrics_parser.py returned: Average latency: 30.00 ms
────────────────────────────────────────
Session: local-648f77d8b520533c510593b1ed77bdcfcbace6d9928a63ce0364b817b58e55f9
Duration: 38s
Messages: 10 (1 user, 8 tool calls)
Monitor system resources while running
In a separate terminal while llama-server is running, inspect its resident set size (RSS). Also inspect the GB10 GPU memory allocation and overall unified memory usage:
ps -o pid=,rss=,comm= -p $(pgrep -n llama-server) | awk '{printf "PID=%s RSS=%.2f GiB CMD=%s\n", $1, $2/1048576, $3}'
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv
free -h
The output is similar to:
PID=1223023 RSS=3.03 GiB CMD=llama-server
pid, process_name, used_gpu_memory [MiB]
1223023, ./build/bin/llama-server, 4088 MiB
With Gemma 4 E4B, the 64K context window, and q8_0 KV cache active, llama-server uses ~4,088 MiB (~4.0 GiB) of GB10 unified GPU memory (3.03 GiB process RSS). It leaves over 115 GB available on a dedicated 128 GB NVIDIA DGX Spark.
Observed agentic performance
The following table summarizes the observed run for Gemma 4 E4B on NVIDIA DGX Spark. The DGX Spark has a Grace Blackwell GB10, 128 GB unified memory, and CUDA sm_121a offload:
| Metric | Gemma 4 E4B (Q4_0, GB10 CUDA) |
|---|---|
| Tool-call format reliability | Clean tool calls (terminal, read_file, patch) |
| Diagnosis and fix accuracy | Identified and patched both bugs cleanly before verification |
| Total wall-clock completion time | 38s (cold ~11K-token prefill, plus 8 tool calls across 10 messages) |
llama-server memory usage | ~3.03 GiB RSS and 4,088 MiB GPU memory in nvidia-smi |
What you’ve accomplished
You’ve connected Nous Research Hermes Agent to your local llama-server endpoint and used it to fix both bugs in metrics_parser.py. You’ve verified the output of the script.
You can extend the Learning Path setup by making the following updates:
- Switch Hermes Agent to Gemma 4 26B-A4B (MoE): Restart
llama-serverwith-m ./models/gemma-4-26B-A4B-it-Q4_0.ggufand runhermes config set model.default ./models/gemma-4-26B-A4B-it-Q4_0.gguf. This allows the agent to gain higher reasoning capacity at 61.72 tok/s GPU decode speed. - Run
llama-serveras asystemdservice: Create a user or systemsystemdunit so that your local inference server starts automatically on boot and restarts cleanly if needed. - Connect local MCP servers to Hermes Agent: Extend Hermes Agent capabilities by attaching model context protocol (MCP) servers for local Git repositories, databases, or documentation search.