Skip to main content

Overview

Raspberry Pi 5 with 8GB RAM can run smaller Gemma model variants locally through compatible runtimes. This guide shows how to add Grantex offline authorization so configured actions are scope-checked and recorded locally without internet connectivity; current revocation state requires later synchronization.

Prerequisites

  • Raspberry Pi 5 (8GB recommended, 4GB minimum for smaller Gemma 4 variants)
  • Raspberry Pi OS (64-bit Bookworm or later)
  • Python 3.10+ (ships with Bookworm)
  • A Grantex account with API key and a registered agent
  • Wi-Fi or Ethernet for initial setup (offline operation starts after provisioning)

Hardware Notes

Gemma 4’s 2B parameter model requires ~4GB of RAM. The 7B model requires an 8GB Pi with swap configured.

Step 1: Install Dependencies

Run this script once while the Pi has internet access. It creates a consent bundle and encrypts it to disk.
Run it:

Step 3: Build the Offline Agent

This is the main agent script. It loads the bundle, creates a verifier and audit log, then runs a loop that checks authorization before every action.
Run it:
Expected output:

Step 4: Sync When Online

Create a sync script that runs when the Pi reconnects:

Performance Considerations

A Raspberry Pi deployment performs these operations locally: Benchmark these operations on the target device and workload. Performance varies with bundle size, key implementation, storage, thermal state, and concurrent inference load.

Production Tips

Log Rotation

The audit log grows by ~200 bytes per entry. At 1 action per second, that is ~17MB per day. Set max_size_mb appropriately for your SD card:
Rotated files are named audit.jsonl.2026-04-03T12-00-00-000Z.bak.

Bundle Refresh Cron

If the Pi connects to Wi-Fi daily, add a cron job to refresh the bundle:
The refresh script:

Systemd Service

Run the agent as a systemd service for automatic restart:

SD Card Wear

Frequent writes to the audit log can wear out SD cards. Mitigations:
  • Use an NVMe SSD via M.2 HAT for write-heavy workloads
  • Set max_size_mb to limit log file growth
  • Use tmpfs for temporary logs and sync to persistent storage periodically

Next Steps

Last modified on July 12, 2026