From ec06564b46665f6108b97cdb60fb1f1d726d85c9 Mon Sep 17 00:00:00 2001 From: dhunganapramod9 Date: Sat, 28 Feb 2026 01:08:55 -0500 Subject: [PATCH] fix(chat_web): validate --num-gpus against available GPUs for clear startup error --- scripts/chat_web.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/chat_web.py b/scripts/chat_web.py index 66d7806..721875f 100644 --- a/scripts/chat_web.py +++ b/scripts/chat_web.py @@ -113,6 +113,11 @@ class WorkerPool: print(f"Initializing worker pool with {self.num_gpus} GPUs...") if self.num_gpus > 1: assert device_type == "cuda", "Only CUDA supports multiple workers/GPUs. cpu|mps does not." + if device_type == "cuda" and self.num_gpus > torch.cuda.device_count(): + raise ValueError( + f"--num-gpus {self.num_gpus} exceeds available GPUs ({torch.cuda.device_count()}). " + "Use a value <= torch.cuda.device_count()." + ) for gpu_id in range(self.num_gpus):