Skip to content

Commit c6b33ac

Browse files
committed
Log clearer error message for insufficient GPUs
1 parent f17f870 commit c6b33ac

File tree

1 file changed

+5
-1
lines changed
  • server/text_generation_server/inference_engine

1 file changed

+5
-1
lines changed

server/text_generation_server/inference_engine/engine.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ def __init__(self, model_path: str, model_config: Optional[Any]) -> None:
2020
self.rank = int(os.getenv("RANK", "0"))
2121
self.world_size = int(os.getenv("WORLD_SIZE", "1"))
2222
if torch.cuda.is_available():
23-
assert self.world_size <= torch.cuda.device_count(), "Each process is one gpu"
23+
gpu_count = torch.cuda.device_count()
24+
assert (
25+
self.world_size <= gpu_count,
26+
f"{self.world_size} shards configured but only {gpu_count} GPUs detected"
27+
)
2428
device_index = self.rank % torch.cuda.device_count()
2529
torch.cuda.set_device(device_index)
2630
self.device = torch.device("cuda", device_index)

0 commit comments

Comments
 (0)