Skip to main content
llmfit provides advanced flags and modes for edge cases, automation, and cluster deployments.

GPU Memory Override

GPU VRAM autodetection can fail on some systems (broken nvidia-smi, VMs, passthrough setups, remote GPUs). Use --memory to manually specify your GPU’s VRAM.
Accepted suffixes:
suffix
Gigabytes (case-insensitive)
suffix
Megabytes (case-insensitive)
suffix
Terabytes (case-insensitive)
Behavior:
  • If no GPU was detected, --memory creates a synthetic GPU entry so models are scored for GPU inference
  • If a GPU was detected but VRAM is unknown or wrong, --memory overrides the detected value
  • Works with all modes: TUI, CLI, subcommands, and serve
Examples:
Use cases:
  • VMs / passthrough: GPU is present but not directly visible to OS
  • Broken nvidia-smi: nvidia-smi reports incorrect VRAM or fails
  • Remote GPUs: Planning for a GPU you don’t have locally
  • Multi-GPU: Override with aggregate VRAM (e.g., 2x 24GB = 48GB)
--memory overrides VRAM only. It does not affect system RAM or CPU detection.

Context Length Cap

Use --max-context to cap the context length used for memory estimation. This does not change each model’s advertised maximum context — it only affects how much memory llmfit assumes the model will use.
Why cap context?
  • Reduce memory usage: Longer context = more memory for KV cache
  • Realistic workloads: You may not need a model’s full 128k context window
  • Fit more models: Capping context can promote a model from “Marginal” to “Good” fit
Memory impact: KV cache size grows linearly with context length:
Example for Llama-3.1-70B:
  • 4K context: ~0.7 GB KV cache
  • 8K context: ~1.4 GB KV cache
  • 128K context: ~22.4 GB KV cache
Fallback: If --max-context is not set, llmfit checks the OLLAMA_CONTEXT_LENGTH environment variable:
This is convenient if you use Ollama and have already configured your context length via OLLAMA_CONTEXT_LENGTH. Examples:
API per-request override: In serve mode, you can override the context cap on a per-request basis with the max_context query parameter:

Remote Ollama

By default, llmfit connects to Ollama at http://localhost:11434. To connect to a remote Ollama instance, set the OLLAMA_HOST environment variable.
Use cases:
  • GPU server + laptop client: Run llmfit on your laptop while Ollama serves from a GPU server
  • Docker containers: Connect to Ollama running in a Docker container with custom ports
  • Reverse proxies: Use Ollama behind a reverse proxy or load balancer
How it works: llmfit makes HTTP requests to:
  • GET $OLLAMA_HOST/api/tags — List installed models
  • POST $OLLAMA_HOST/api/pull — Download models
The TUI shows install status and download progress for the remote Ollama instance. Example workflow:
This allows you to use llmfit’s TUI on your local machine while managing models on a remote GPU server.
Combine OLLAMA_HOST with --memory to plan models for a remote GPU:

Serve Mode for Cluster Scheduling

The serve subcommand starts an HTTP API that exposes node-local model fit analysis. This is designed for cluster schedulers, aggregators, and remote clients that need to query hardware compatibility across multiple nodes.
Key endpoints:
endpoint
Liveness probe. Returns {"status": "ok", "node": {...}}
endpoint
Node hardware info (CPU, RAM, GPU, backend)
endpoint
Full fit list with filters (limit, min_fit, runtime, use_case, etc.)
endpoint
Top runnable models for scheduling (conservative defaults: limit=5, min_fit=good)
See REST API Guide for full endpoint documentation, query parameters, and response schemas. Cluster scheduling workflow:
  1. Run llmfit serve on each node in your cluster
  2. From your scheduler, poll each node:
  3. Aggregate results and decide which node to schedule a model on
  4. Send deploy command to chosen node
Example aggregator (Python):
Conservative placement defaults: For production placement, prefer:
This ensures only models that fit with headroom are considered.

Environment Variables

llmfit respects the following environment variables:
string
default:"http://localhost:11434"
Ollama API URL. Set to connect to remote Ollama instances.Example:
integer
Context length fallback for memory estimation when --max-context is not set.Example:
This is useful if you use Ollama and have already configured your context length via OLLAMA_CONTEXT_LENGTH.
Priority:
  1. --max-context flag (highest priority)
  2. OLLAMA_CONTEXT_LENGTH environment variable
  3. Model’s full advertised context (default, lowest priority)

Combining Flags

All global flags can be combined:

Advanced Workflows

1. Multi-GPU Aggregate VRAM

If you have multiple GPUs with shared VRAM pool (e.g., NVLink), override with total VRAM:
llmfit will score models as if you have a single 320GB GPU.

2. Planning for Future Hardware

Use --memory to plan models for a GPU you don’t have yet:

3. Workload-Specific Context Caps

Chat workload (short conversations):
Code analysis (medium context):
Long documents (full context):

4. Remote Hardware Inspection

SSH into a remote node and check its hardware without installing llmfit:

5. Kubernetes Cluster Scheduling

Deploy llmfit as a DaemonSet on all GPU nodes:
Then query each node’s API from your scheduler:

Performance Considerations

TUI Startup Time

The TUI probes all providers (Ollama, MLX, llama.cpp) on startup. On slow networks or with many installed models, this can take 1-2 seconds. To skip provider detection, use CLI mode:

API Response Time

The REST API computes fit analysis on each request. For large model databases (200+ models), this takes ~50-100ms. To reduce latency:
  • Use limit parameter to reduce result set
  • Use min_fit=good to exclude unrunnable models
  • Cache results on the client side if hardware doesn’t change

Download Speed

  • Ollama: Controlled by Ollama daemon (typically saturates bandwidth)
  • llama.cpp: Direct HuggingFace download (typically faster than Ollama)
  • MLX: Direct HuggingFace download via mlx_lm (similar to llama.cpp)
To maximize download speed, use llama.cpp or MLX instead of Ollama.

Troubleshooting

GPU Not Detected

Symptom: TUI shows “GPU: none” even though you have a GPU. Causes:
  • nvidia-smi not in PATH or not working
  • VM/passthrough setup where GPU is not visible to OS
  • AMD GPU without rocm-smi
  • Intel Arc without proper drivers
Solution: Use --memory to override:

Wrong VRAM Amount

Symptom: TUI shows incorrect VRAM (e.g., 16GB instead of 24GB). Causes:
  • nvidia-smi reporting bug
  • Shared memory incorrectly reported
  • Multi-GPU with incorrect aggregation
Solution: Use --memory to override:

Models Don’t Fit as Expected

Symptom: Models you think should fit are marked “Too Tight”. Causes:
  • Context length too high (KV cache uses a lot of memory)
  • Available RAM lower than you think (OS overhead, other processes)
  • Model requires more memory than you expect (MoE inactive experts, etc.)
Solution: Cap context length:
Or check actual available RAM:

Ollama Not Detected

Symptom: TUI shows “Ollama: ✗” even though Ollama is running. Causes:
  • Ollama running on non-default port
  • Firewall blocking localhost:11434
  • Ollama not fully started yet
Solution: Set OLLAMA_HOST:
Or wait a few seconds and restart llmfit.

Download Fails

Symptom: Download starts but fails with an error. Causes:
  • Network error (HuggingFace unreachable)
  • Disk full
  • Ollama daemon stopped mid-download
  • GGUF repo not found
Solution:
  1. Check network: curl -I https://huggingface.co
  2. Check disk space: df -h
  3. Restart Ollama: ollama serve
  4. Try a different provider (Ollama vs llama.cpp)
Use llmfit --memory <size> system to verify that the override is applied correctly before running fit analysis.
All advanced flags (--memory, --max-context, OLLAMA_HOST) work in TUI, CLI, and serve modes. In serve mode, they affect all API responses.