Skip to content

Commit 347e6d8

Browse files
committed
feat(vmm-cli): support --gpu all to attach all GPUs
Add support for using '--gpu all' as an alternative to '--ppcie' for attaching all available GPUs to a VM. This works for both deploy and update commands. Examples: vmm-cli.py deploy --gpu all ... vmm-cli.py update <vm-id> --gpu all
1 parent 9e273d0 commit 347e6d8

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

vmm/src/vmm-cli.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def create_vm(self, args) -> None:
591591
if swap_bytes > 0:
592592
params["swap_size"] = swap_bytes
593593

594-
if args.ppcie:
594+
if args.ppcie or (args.gpu and "all" in args.gpu):
595595
params["gpus"] = {
596596
"attach_mode": "all"
597597
}
@@ -831,8 +831,9 @@ def update_vm(
831831
upgrade_params["ports"] = port_mappings
832832

833833
# handle GPU updates - only update if one of the GPU flags is set
834-
if attach_all or no_gpus or gpu_slots is not None:
835-
if attach_all:
834+
gpu_all = gpu_slots and "all" in gpu_slots
835+
if attach_all or gpu_all or no_gpus or gpu_slots is not None:
836+
if attach_all or gpu_all:
836837
gpu_config = {"attach_mode": "all"}
837838
updates.append("GPUs (all)")
838839
elif no_gpus:
@@ -1264,7 +1265,7 @@ def main():
12641265
deploy_parser.add_argument('--port', action='append', type=str,
12651266
help='Port mapping in format: protocol[:address]:from:to')
12661267
deploy_parser.add_argument('--gpu', action='append', type=str,
1267-
help='GPU slot to attach (can be used multiple times)')
1268+
help='GPU slot to attach (can be used multiple times), or "all" to attach all GPUs')
12681269
deploy_parser.add_argument('--ppcie', action='store_true',
12691270
help='Enable PPCIE (Protected PCIe) mode - attach all available GPUs')
12701271
deploy_parser.add_argument('--pin-numa', action='store_true',
@@ -1407,7 +1408,7 @@ def main():
14071408
"--gpu",
14081409
action="append",
14091410
type=str,
1410-
help="GPU slot to attach (can be used multiple times)",
1411+
help="GPU slot to attach (can be used multiple times), or \"all\" to attach all GPUs",
14111412
)
14121413
gpu_group.add_argument(
14131414
"--ppcie",

0 commit comments

Comments
 (0)