-cpu flag
This commit is contained in:
@@ -15,7 +15,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from .downloader import compute_shard_checksum, download_shard
|
||||
from .hardware import detect_hardware, benchmark_throughput_checked
|
||||
from .hardware import detect_hardware, benchmark_throughput_checked, with_forced_cpu
|
||||
from .model_catalog import model_metadata_for
|
||||
from .relay_bridge import RelayHttpBridge, peer_id_from_wallet
|
||||
from .server import StubNodeServer
|
||||
@@ -640,6 +640,7 @@ def run_startup(
|
||||
torch_threads: int | None = None,
|
||||
torch_interop_threads: int | None = None,
|
||||
node_name: str | None = None,
|
||||
force_cpu: bool = False,
|
||||
) -> StubNodeServer | TorchNodeServer:
|
||||
"""Execute the full startup sequence and return a running node server.
|
||||
|
||||
@@ -681,6 +682,8 @@ def run_startup(
|
||||
|
||||
print("Detecting hardware...", flush=True)
|
||||
hw = detect_hardware()
|
||||
if force_cpu:
|
||||
hw = with_forced_cpu(hw)
|
||||
torch_thread_config = _configure_torch_threads(torch_threads, torch_interop_threads)
|
||||
if torch_thread_config:
|
||||
hw.update(torch_thread_config)
|
||||
@@ -697,6 +700,16 @@ def run_startup(
|
||||
vram_mb = vram_mb_override
|
||||
shared_vram_mb = 0
|
||||
print(f" Memory budget overridden to {vram_mb / 1024:.1f} GB via --memory", flush=True)
|
||||
elif force_cpu:
|
||||
if gpu_name and vram_mb > 0:
|
||||
print(
|
||||
f" --cpu: ignoring {gpu_name} "
|
||||
f"({vram_mb / 1024:.1f} GB VRAM); running in CPU mode "
|
||||
f"({ram_mb / 1024:.1f} GB RAM)",
|
||||
flush=True,
|
||||
)
|
||||
else:
|
||||
print(f" --cpu: running in CPU mode ({ram_mb / 1024:.1f} GB RAM)", flush=True)
|
||||
elif device == "cpu":
|
||||
gpu_suffix = ""
|
||||
if gpu_name and vram_mb > 0:
|
||||
@@ -718,7 +731,7 @@ def run_startup(
|
||||
print(f" Memory budget: {memory_budget_mb / 1024:.1f} GB {memory_budget_source}", flush=True)
|
||||
|
||||
print("Benchmarking compute...", flush=True)
|
||||
if device != "cuda" and gpu_name:
|
||||
if device != "cuda" and gpu_name and not force_cpu:
|
||||
_cuda_score, cuda_ok, cuda_error = benchmark_throughput_checked("cuda")
|
||||
hw["cuda_benchmark_ok"] = cuda_ok
|
||||
if cuda_error:
|
||||
@@ -833,6 +846,7 @@ def run_startup(
|
||||
cache_dir=cache_dir,
|
||||
debug=debug,
|
||||
max_loaded_shards=max_loaded_shards,
|
||||
force_cpu=force_cpu,
|
||||
)
|
||||
_node_start_time = time.monotonic()
|
||||
actual_port = node.start()
|
||||
@@ -986,6 +1000,7 @@ def run_startup(
|
||||
cache_dir=cache_dir,
|
||||
debug=debug,
|
||||
max_loaded_shards=max_loaded_shards,
|
||||
force_cpu=force_cpu,
|
||||
)
|
||||
_node_start_time = time.monotonic()
|
||||
actual_port = node.start()
|
||||
@@ -1163,6 +1178,7 @@ def run_startup(
|
||||
cache_dir=shard_path,
|
||||
debug=debug,
|
||||
max_loaded_shards=max_loaded_shards,
|
||||
force_cpu=force_cpu,
|
||||
)
|
||||
actual_port = node.start()
|
||||
total_layers = getattr(getattr(node, "backend", None), "total_layers", None) or assigned_total_layers
|
||||
|
||||
Reference in New Issue
Block a user