Initial llm-host: hardware-aware local LLM server with dashboard
Detects the GPU (NVIDIA on Linux, Apple Silicon on macOS), picks the catalog models and builds that fit, installs vLLM or MLX without sudo, and runs the model server plus a web dashboard as user services. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
This commit is contained in:
commit
5b9586ac80
19 changed files with 2458 additions and 0 deletions
47
llmhost/hfcache.py
Normal file
47
llmhost/hfcache.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"""Read-only checks against the Hugging Face cache (no huggingface_hub dependency)."""
|
||||
import json
|
||||
import os
|
||||
|
||||
from . import paths
|
||||
|
||||
|
||||
def repo_dir(repo):
|
||||
return paths.hf_hub_dir() / ("models--" + repo.replace("/", "--"))
|
||||
|
||||
|
||||
def is_downloaded(repo):
|
||||
"""True when a snapshot has every weight file its index lists (or a single-file model)."""
|
||||
snaps = repo_dir(repo) / "snapshots"
|
||||
if not snaps.is_dir():
|
||||
return False
|
||||
for snap in snaps.iterdir():
|
||||
idx = snap / "model.safetensors.index.json"
|
||||
if idx.exists():
|
||||
try:
|
||||
files = set(json.loads(idx.read_text())["weight_map"].values())
|
||||
except (OSError, ValueError, KeyError):
|
||||
continue
|
||||
if files and all(os.path.exists(snap / f) for f in files):
|
||||
return True
|
||||
elif (snap / "model.safetensors").exists():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def disk_gib(repo):
|
||||
"""Size of this repo's downloaded files, in GiB. Measured through the snapshot symlinks
|
||||
because newer huggingface_hub versions keep large blobs in a shared hub/blobs directory."""
|
||||
seen, total = set(), 0
|
||||
snaps = repo_dir(repo) / "snapshots"
|
||||
if snaps.is_dir():
|
||||
for root, _dirs, files in os.walk(snaps):
|
||||
for name in files:
|
||||
real = os.path.realpath(os.path.join(root, name))
|
||||
if real in seen:
|
||||
continue
|
||||
seen.add(real)
|
||||
try:
|
||||
total += os.stat(real).st_size
|
||||
except OSError:
|
||||
pass
|
||||
return total / 2**30
|
||||
Loading…
Add table
Add a link
Reference in a new issue