Skip to content

Commit d706489

Browse files
authored
Add GPU allocation logic for EmptyLauncher in infinity_emb command generation (#514)
1 parent 29ddead commit d706489

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lazyllm/components/deploy/infinity.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ def impl():
6060
if self.random_port:
6161
self.kw['port'] = random.randint(30000, 40000)
6262
cmd = f'infinity_emb v2 --model-id {finetuned_model} '
63+
if isinstance(self.launcher, launchers.EmptyLauncher) and self.launcher.ngpus:
64+
available_gpus = self.launcher._get_idle_gpus()
65+
required_count = self.launcher.ngpus
66+
if required_count <= len(available_gpus):
67+
gpu_ids = ','.join(map(str, available_gpus[:required_count]))
68+
cmd += f'--device-id={gpu_ids} '
69+
else:
70+
raise RuntimeError(
71+
f"Insufficient GPUs available (required: {required_count}, "
72+
f"available: {len(available_gpus)})"
73+
)
6374
cmd += self.kw.parse_kwargs()
6475
if self.temp_folder: cmd += f' 2>&1 | tee {get_log_path(self.temp_folder)}'
6576
return cmd

0 commit comments

Comments
 (0)