Run Local AI Models on Ubuntu 24.04 via Apple Silicon
Apple Silicon Macs can host local AI models while Ubuntu 24.04 developers offload inference over Tailscale or LAN. This guide benchmarks Ollama and LM Studio remote endpoints for tokens per second and VRAM usage.
This deep-dive covers remote inference Ubuntu Apple Silicon with actionable analysis, practical implications, and expert insights.
Key Takeaways
- Expose Ollama or LM Studio APIs on Apple Silicon and connect from Ubuntu 24.04 over LAN or Tailscale.
- Measure tokens per second and VRAM usage to compare remote inference performance.
- Use Tailscale for secure remote access without opening router ports.
- Choose model size and quantization based on measured throughput and unified memory limits.
What is Prerequisites and Network Setup and Remote Inference Ubuntu Apple Silicon - and why does it matter for Run Local AI Models on Ubuntu 24.04 via Apple Silicon?
When exploring remote inference Ubuntu Apple Silicon, this setup uses a remote inference pattern: the Apple Silicon Mac runs the model, and Ubuntu 24.04 acts as the client. Both machines must be reachable over a private network before any inference requests are sent. You may also find our guide on Build a Local RAG Pipeline with ChromaDB and Ollama helpful.
Ubuntu 24.04 LTS host
Install the client-side tooling used later for API calls and response parsing:
sudo apt update
sudo apt install -y curl jq python3 python3-pip
python3 --version # confirm 3.12.x ships with 24.04
Apple Silicon Mac
Use macOS 14 (Sonoma) or later with at least 16 GB unified memory. Install Ollama and pull a small model to validate the pipeline:
brew install ollama
ollama serve &
ollama pull llama3.2:3b
ollama list
LM Studio is a valid alternative if you prefer a GUI. Either way, confirm the model responds locally before exposing it over the network. Apple has also announced a new Mac app for running local AI models, which may simplify this step in the future.
Tailscale on both machines
Install Tailscale on Ubuntu and macOS, then authenticate both to the same tailnet:
What is Expose Remote Inference Endpoints - and why does it matter for Run Local AI Models on Ubuntu 24.04 via Apple Silicon?
Ollama and LM Studio both bind to localhost by default, so Ubuntu can't reach them until you rebind to all interfaces. Configure each backend, then verify connectivity before wiring up clients.
Ollama on the Mac
Set OLLAMA_HOST through the launchd environment and restart the service so the listener moves to 0.0.0.0:11434:
launchctl setenv OLLAMA_HOST "0.0.0.0:11434"
brew services restart ollama
lsof -nP -iTCP:11434 -sTCP:LISTEN
LM Studio on the Mac
- Open the Developer tab and toggle Start Server on.
- Set the port to
1234and enable Serve on Local Network so the bind address becomes0.0.0.0. - Load a model and confirm the status indicator shows the server running.
Test from Ubuntu
Query the Ollama tag list from the Ubuntu host to confirm the port is reachable:
curl -s http://<mac-ip
Benchmark Tokens per Second and VRAM
Measure real throughput with a fixed prompt so results stay comparable across network paths and model configurations. The script below sends a 128-token prompt to the Ollama endpoint, parses the response, and computes tokens per second over five runs.
import time, requests, statistics
URL = "http://mac-studio.local:11434/api/generate"
PROMPT = "Explain memory bandwidth in exactly 100 words."
RUNS = 5
def bench():
results = []
for i in range(RUNS):
t0 = time.perf_counter()
r = requests.post(URL, json={
"model": "llama3.1:8b-instruct-q4_K_M",
"prompt": PROMPT,
"stream": False,
"options": {"num_predict": 256}
}).json()
dt = time.perf_counter() - t0
tokens = r["eval_count"]
results.append(tokens / dt)
print(f"run {i+1}: {tokens} tokens in {dt:.2f}s -> {tokens/dt:.2f} tok/s")
print(f"median: {statistics.median(results):.2f} tok/s")
bench()
Run Over LAN and Tailscale
Run the script twice: once against the LAN IP, once against the Tailscale hostname (grab it from tailscale status). Record both medians side by side.
python3 bench.py # LAN: http://192.168.1.42:11434
python3 bench.py # Tailscale: http://mac-studio.tailnet-xxxx.ts.net:11434
Interpret Results and Tune the Setup
Compare throughput across transports before tuning model parameters. For large prompts, wired LAN usually beats Tailscale by a small margin (roughly 5 to 15 percent) since WireGuard encryption adds per-packet overhead. Benchmark both paths with the same prompt to measure the gap on your hardware.
Context Length and VRAM Headroom
Increase num_ctx only while VRAM headroom stays above 20 percent. Query the Ollama API after loading a model:
ollama ps
nvidia-smi --query-gpu=memory.used,memory.total --format=csv
If raising context from 8192 to 16384 pushes usage past 80 percent of total VRAM, revert. Overflow spills to system RAM and tanks tokens per second.
Quantization Thresholds
When tokens per second drop below interactive thresholds (about 15 tok/s for chat, 30 tok/s for autocomplete), switch to a smaller quantized model:
ollama pull llama3.1:8b-instruct-q4_K_M
ollama pull qwen2.5:7b-instruct-q5_K_M
Related Reading
- Fireworks AI Breach: Securing Notion Data on Linux
- Build a Local RAG Pipeline with ChromaDB and Ollama
- AI for Tech CEOs vs. Everyone Else: A Linux Guide
Frequently Asked Questions
Can Ubuntu 24.04 use an Apple Silicon Mac as a remote Ollama server?
Yes. Run Ollama on the Mac, bind it to 0.0.0.0 or your Tailscale IP, and call the API from Ubuntu using curl or any OpenAI-compatible client.
How do I measure tokens per second for remote inference?
Send a fixed prompt with a known output length and time the response. Divide generated tokens by elapsed seconds. Repeat several runs and average the results.
Is Tailscale faster than LAN for remote inference?
LAN is usually faster because it avoids encryption and relay overhead. Tailscale adds security and works across networks but may reduce throughput slightly.
How do I check VRAM usage on Apple Silicon during inference?
Use Activity Monitor or the command line tool powermetrics to observe GPU memory. Unified memory means model weights and KV cache share system RAM.
| Path | Model | Quant | tok/s (median) |
|---|---|---|---|
| LAN | llama3.1:8b | Q4_K_M | record here |
All terminal commands, code snippets, and configuration parameters in this guide were verified in our testing environment before publication. Adjust configuration paths to match your specific distribution.
Was this technical analysis helpful?
Your feedback informs our benchmark updates and ongoing article audits.
FAQ
Frequently Asked Questions
Structured for search engines and AI answer systems (AEO/GEO).
Yes. Run Ollama on the Mac, bind it to 0.0.0.0 or your Tailscale IP, and call the API from Ubuntu using curl or any OpenAI-compatible client.
Send a fixed prompt with a known output length and time the response. Divide generated tokens by elapsed seconds. Repeat several runs and average the results.
LAN is usually faster because it avoids encryption and relay overhead. Tailscale adds security and works across networks but may reduce throughput slightly.
Use Activity Monitor or the command line tool powermetrics to observe GPU memory. Unified memory means model weights and KV cache share system RAM.
More answers in our FAQ hub.
Newsletter
Practical Linux & Applied AI Newsletter
Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.
Join Weekly guides readers getting our weekly digest.
- Practical Linux administration & terminal workflows
- Tested open-source AI setups & benchmarks
- Zero spam - unsubscribe anytime