Enhance LLM configuration and installation scripts for improved flexibility
- Added new environment variables in `env.example` and `gpu-rent.vars.example` for fine-tuning LLM settings, including CUDA build options and model version pinning. - Updated `llm.md` documentation to include detailed descriptions of new configuration options and usage cases for LLM setups. - Enhanced the `provision.py` script to forward new environment variables during remote installations, improving the installation process for LLM components. - Modified the `install_llamacpp.sh` script to support conditional CUDA builds and asset URL overrides, ensuring better compatibility with various environments. - Improved logging in the installation scripts to provide clearer feedback during the setup process.
This commit is contained in:
@@ -29,6 +29,32 @@ from gpu_rent.sync_files import pull_tree, push_tree
|
||||
Log = Callable[[str], None]
|
||||
DATA = "/mnt/swarm_data"
|
||||
|
||||
# Forwarded to remote install_*.sh (from .env / gpu-rent.vars → os.environ).
|
||||
_OLLAMA_INSTALL_ENV = ("OLLAMA_VERSION", "OLLAMA_SHA256")
|
||||
_LLAMACPP_INSTALL_ENV = (
|
||||
"LLAMACPP_TAG",
|
||||
"LLAMACPP_ASSET_URL",
|
||||
"LLAMACPP_SHA256",
|
||||
"LLAMACPP_BUILD_CUDA",
|
||||
"LLAMACPP_FORCE_REINSTALL",
|
||||
"LLAMACPP_NGL",
|
||||
"LLAMACPP_CTX",
|
||||
"LLAMACPP_HOST",
|
||||
"LLAMACPP_PORT",
|
||||
"LLAMACPP_EXTRA_ARGS",
|
||||
)
|
||||
|
||||
|
||||
def _remote_llm_env(cfg: Config, *keys: str) -> dict[str, str]:
|
||||
import os
|
||||
|
||||
env: dict[str, str] = {"SWARM_USER": cfg.ssh_user}
|
||||
for key in keys:
|
||||
value = (os.environ.get(key) or "").strip()
|
||||
if value:
|
||||
env[key] = value
|
||||
return env
|
||||
|
||||
|
||||
def _pkg_text(name: str) -> str:
|
||||
return files("gpu_rent.remote").joinpath(name).read_text(encoding="utf-8")
|
||||
@@ -442,7 +468,7 @@ def provision_llm(cfg: Config, host: str, log: Log) -> None:
|
||||
_pkg_text("install_ollama.sh"),
|
||||
remote_path="/tmp/gpu-rent-install_ollama.sh",
|
||||
timeout=900,
|
||||
env={"SWARM_USER": cfg.ssh_user},
|
||||
env=_remote_llm_env(cfg, *_OLLAMA_INSTALL_ENV),
|
||||
log=log,
|
||||
)
|
||||
entries = parse_ollama_models(cfg.ollama_models_manifest)
|
||||
@@ -516,13 +542,16 @@ def provision_llm(cfg: Config, host: str, log: Log) -> None:
|
||||
else:
|
||||
log("llamacpp-models.yaml пуст — GGUF skip (положи вручную)")
|
||||
log("LLM: ставим/запускаем llama.cpp server")
|
||||
import os
|
||||
|
||||
build_cuda = (os.environ.get("LLAMACPP_BUILD_CUDA") or "").strip() == "1"
|
||||
run_script_sudo(
|
||||
cfg,
|
||||
host,
|
||||
_pkg_text("install_llamacpp.sh"),
|
||||
remote_path="/tmp/gpu-rent-install_llamacpp.sh",
|
||||
timeout=1200,
|
||||
env={"SWARM_USER": cfg.ssh_user},
|
||||
timeout=3600 if build_cuda else 1200,
|
||||
env=_remote_llm_env(cfg, *_LLAMACPP_INSTALL_ENV),
|
||||
log=log,
|
||||
)
|
||||
st = load_state()
|
||||
|
||||
Reference in New Issue
Block a user