perf: cap torch threads per camera worker

Default TORCH_NUM_THREADS=1 so 14-20 workers do not each spawn a
28-thread BLAS pool.
This commit is contained in:
root
2026-08-28 06:17:33 +00:00
parent 950128deec
commit 23c2e9c4c0
6 changed files with 34 additions and 2 deletions
+4
View File
@@ -40,6 +40,7 @@ class Config:
enhance_hop_s: float = 0.2
# SpeechBrain Delay-and-Sum (GCC-PHAT) on C920 stereo before enhance
beamform_mode: str = "auto" # auto | force | off
torch_num_threads: int = 1
# misc
publish_timeout_s: float = 60.0
log_level: str = "INFO"
@@ -86,6 +87,7 @@ def load_config(env_path: Optional[Path] = None) -> Config:
enhance_chunk_s=float(os.environ.get("ENHANCE_CHUNK_S", "1.0")),
enhance_hop_s=float(os.environ.get("ENHANCE_HOP_S", "0.2")),
beamform_mode=os.environ.get("BEAMFORM_MODE", "auto").lower(),
torch_num_threads=int(os.environ.get("TORCH_NUM_THREADS", "1")),
publish_timeout_s=float(os.environ.get("PUBLISH_TIMEOUT_S", "60")),
log_level=os.environ.get("LOG_LEVEL", "INFO").upper(),
cameras=_parse_cameras(os.environ.get("CAMERAS", "all")),
@@ -96,4 +98,6 @@ def load_config(env_path: Optional[Path] = None) -> Config:
if cfg.beamform_mode not in ("auto", "force", "off"):
raise ValueError(
f"BEAMFORM_MODE must be auto|force|off, got {cfg.beamform_mode}")
if cfg.torch_num_threads < 1:
raise ValueError("TORCH_NUM_THREADS must be >= 1")
return cfg