@@ -174,6 +174,13 @@ def _interactive_node_cli_command(cli_func):
174
174
default = None ,
175
175
type = str ,
176
176
help = 'Instance type to use.' )
177
+ cpus = click .option (
178
+ '--cpus' ,
179
+ default = None ,
180
+ type = str ,
181
+ help = ('Number of vCPUs each instance must have '
182
+ '(e.g., ``--cpus=4`` (exactly 4) or ``--cpus=4+`` (at least 4)). '
183
+ 'This is used to automatically select the instance type.' ))
177
184
gpus = click .option ('--gpus' ,
178
185
default = None ,
179
186
type = str ,
@@ -268,6 +275,7 @@ def _interactive_node_cli_command(cli_func):
268
275
region_option ,
269
276
zone_option ,
270
277
instance_type_option ,
278
+ cpus ,
271
279
* ([gpus ] if cli_func .__name__ == 'gpunode' else []),
272
280
* ([tpus ] if cli_func .__name__ == 'tpunode' else []),
273
281
spot_option ,
@@ -556,6 +564,7 @@ def _parse_override_params(cloud: Optional[str] = None,
556
564
region : Optional [str ] = None ,
557
565
zone : Optional [str ] = None ,
558
566
gpus : Optional [str ] = None ,
567
+ cpus : Optional [str ] = None ,
559
568
instance_type : Optional [str ] = None ,
560
569
use_spot : Optional [bool ] = None ,
561
570
image_id : Optional [str ] = None ,
@@ -582,6 +591,11 @@ def _parse_override_params(cloud: Optional[str] = None,
582
591
override_params ['accelerators' ] = None
583
592
else :
584
593
override_params ['accelerators' ] = gpus
594
+ if cpus is not None :
595
+ if cpus .lower () == 'none' :
596
+ override_params ['cpus' ] = None
597
+ else :
598
+ override_params ['cpus' ] = cpus
585
599
if instance_type is not None :
586
600
if instance_type .lower () == 'none' :
587
601
override_params ['instance_type' ] = None
@@ -908,6 +922,7 @@ def _make_task_from_entrypoint_with_overrides(
908
922
region : Optional [str ] = None ,
909
923
zone : Optional [str ] = None ,
910
924
gpus : Optional [str ] = None ,
925
+ cpus : Optional [str ] = None ,
911
926
instance_type : Optional [str ] = None ,
912
927
num_nodes : Optional [int ] = None ,
913
928
use_spot : Optional [bool ] = None ,
@@ -949,6 +964,7 @@ def _make_task_from_entrypoint_with_overrides(
949
964
region = region ,
950
965
zone = zone ,
951
966
gpus = gpus ,
967
+ cpus = cpus ,
952
968
instance_type = instance_type ,
953
969
use_spot = use_spot ,
954
970
image_id = image_id ,
@@ -1090,6 +1106,13 @@ def cli():
1090
1106
default = False ,
1091
1107
help = 'If used, runs locally inside a docker container.' )
1092
1108
@_add_click_options (_TASK_OPTIONS + _EXTRA_RESOURCES_OPTIONS )
1109
+ @click .option ('--cpus' ,
1110
+ default = None ,
1111
+ type = str ,
1112
+ required = False ,
1113
+ help = ('Number of vCPUs each instance must have (e.g., '
1114
+ '``--cpus=4`` (exactly 4) or ``--cpus=4+`` (at least 4)). '
1115
+ 'This is used to automatically select the instance type.' ))
1093
1116
@click .option ('--disk-size' ,
1094
1117
default = None ,
1095
1118
type = int ,
@@ -1154,6 +1177,7 @@ def launch(
1154
1177
region : Optional [str ],
1155
1178
zone : Optional [str ],
1156
1179
gpus : Optional [str ],
1180
+ cpus : Optional [str ],
1157
1181
instance_type : Optional [str ],
1158
1182
num_nodes : Optional [int ],
1159
1183
use_spot : Optional [bool ],
@@ -1198,6 +1222,7 @@ def launch(
1198
1222
region = region ,
1199
1223
zone = zone ,
1200
1224
gpus = gpus ,
1225
+ cpus = cpus ,
1201
1226
instance_type = instance_type ,
1202
1227
num_nodes = num_nodes ,
1203
1228
use_spot = use_spot ,
@@ -1343,6 +1368,7 @@ def exec(
1343
1368
region = region ,
1344
1369
zone = zone ,
1345
1370
gpus = gpus ,
1371
+ cpus = None ,
1346
1372
instance_type = instance_type ,
1347
1373
use_spot = use_spot ,
1348
1374
image_id = image_id ,
@@ -2414,11 +2440,11 @@ def _down_or_stop(name: str):
2414
2440
# pylint: disable=redefined-outer-name
2415
2441
def gpunode (cluster : str , yes : bool , port_forward : Optional [List [int ]],
2416
2442
cloud : Optional [str ], region : Optional [str ], zone : Optional [str ],
2417
- instance_type : Optional [str ], gpus : Optional [str ],
2418
- use_spot : Optional [bool ], screen : Optional [bool ],
2419
- tmux : Optional [bool ], disk_size : Optional [int ],
2420
- idle_minutes_to_autostop : Optional [int ], down : bool ,
2421
- retry_until_up : bool ):
2443
+ instance_type : Optional [str ], cpus : Optional [str ],
2444
+ gpus : Optional [str ], use_spot : Optional [bool ],
2445
+ screen : Optional [bool ], tmux : Optional [bool ],
2446
+ disk_size : Optional [int ], idle_minutes_to_autostop : Optional [ int ] ,
2447
+ down : bool , retry_until_up : bool ):
2422
2448
"""Launch or attach to an interactive GPU node.
2423
2449
2424
2450
Examples:
@@ -2457,7 +2483,8 @@ def gpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2457
2483
2458
2484
user_requested_resources = not (cloud is None and region is None and
2459
2485
zone is None and instance_type is None and
2460
- gpus is None and use_spot is None )
2486
+ cpus is None and gpus is None and
2487
+ use_spot is None )
2461
2488
default_resources = _INTERACTIVE_NODE_DEFAULT_RESOURCES ['gpunode' ]
2462
2489
cloud_provider = clouds .CLOUD_REGISTRY .from_str (cloud )
2463
2490
if gpus is None and instance_type is None :
@@ -2470,6 +2497,7 @@ def gpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2470
2497
region = region ,
2471
2498
zone = zone ,
2472
2499
instance_type = instance_type ,
2500
+ cpus = cpus ,
2473
2501
accelerators = gpus ,
2474
2502
use_spot = use_spot ,
2475
2503
disk_size = disk_size )
@@ -2493,10 +2521,11 @@ def gpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2493
2521
# pylint: disable=redefined-outer-name
2494
2522
def cpunode (cluster : str , yes : bool , port_forward : Optional [List [int ]],
2495
2523
cloud : Optional [str ], region : Optional [str ], zone : Optional [str ],
2496
- instance_type : Optional [str ], use_spot : Optional [bool ],
2497
- screen : Optional [bool ], tmux : Optional [bool ],
2498
- disk_size : Optional [int ], idle_minutes_to_autostop : Optional [int ],
2499
- down : bool , retry_until_up : bool ):
2524
+ instance_type : Optional [str ], cpus : Optional [str ],
2525
+ use_spot : Optional [bool ], screen : Optional [bool ],
2526
+ tmux : Optional [bool ], disk_size : Optional [int ],
2527
+ idle_minutes_to_autostop : Optional [int ], down : bool ,
2528
+ retry_until_up : bool ):
2500
2529
"""Launch or attach to an interactive CPU node.
2501
2530
2502
2531
Examples:
@@ -2534,7 +2563,7 @@ def cpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2534
2563
2535
2564
user_requested_resources = not (cloud is None and region is None and
2536
2565
zone is None and instance_type is None and
2537
- use_spot is None )
2566
+ cpus is None and use_spot is None )
2538
2567
default_resources = _INTERACTIVE_NODE_DEFAULT_RESOURCES ['cpunode' ]
2539
2568
cloud_provider = clouds .CLOUD_REGISTRY .from_str (cloud )
2540
2569
if instance_type is None :
@@ -2545,6 +2574,7 @@ def cpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2545
2574
region = region ,
2546
2575
zone = zone ,
2547
2576
instance_type = instance_type ,
2577
+ cpus = cpus ,
2548
2578
use_spot = use_spot ,
2549
2579
disk_size = disk_size )
2550
2580
@@ -2567,11 +2597,12 @@ def cpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2567
2597
# pylint: disable=redefined-outer-name
2568
2598
def tpunode (cluster : str , yes : bool , port_forward : Optional [List [int ]],
2569
2599
region : Optional [str ], zone : Optional [str ],
2570
- instance_type : Optional [str ], tpus : Optional [str ],
2571
- use_spot : Optional [bool ], tpu_vm : Optional [bool ],
2572
- screen : Optional [bool ], tmux : Optional [bool ],
2573
- disk_size : Optional [int ], idle_minutes_to_autostop : Optional [int ],
2574
- down : bool , retry_until_up : bool ):
2600
+ instance_type : Optional [str ], cpus : Optional [str ],
2601
+ tpus : Optional [str ], use_spot : Optional [bool ],
2602
+ tpu_vm : Optional [bool ], screen : Optional [bool ],
2603
+ tmux : Optional [bool ], disk_size : Optional [int ],
2604
+ idle_minutes_to_autostop : Optional [int ], down : bool ,
2605
+ retry_until_up : bool ):
2575
2606
"""Launch or attach to an interactive TPU node.
2576
2607
2577
2608
Examples:
@@ -2608,8 +2639,8 @@ def tpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2608
2639
name = _default_interactive_node_name ('tpunode' )
2609
2640
2610
2641
user_requested_resources = not (region is None and zone is None and
2611
- instance_type is None and tpus is None and
2612
- use_spot is None )
2642
+ instance_type is None and cpus is None and
2643
+ tpus is None and use_spot is None )
2613
2644
default_resources = _INTERACTIVE_NODE_DEFAULT_RESOURCES ['tpunode' ]
2614
2645
accelerator_args = default_resources .accelerator_args
2615
2646
if tpu_vm :
@@ -2625,6 +2656,7 @@ def tpunode(cluster: str, yes: bool, port_forward: Optional[List[int]],
2625
2656
region = region ,
2626
2657
zone = zone ,
2627
2658
instance_type = instance_type ,
2659
+ cpus = cpus ,
2628
2660
accelerators = tpus ,
2629
2661
accelerator_args = accelerator_args ,
2630
2662
use_spot = use_spot ,
@@ -2967,6 +2999,13 @@ def spot():
2967
2999
** _get_shell_complete_args (_complete_file_name ))
2968
3000
# TODO(zhwu): Add --dryrun option to test the launch command.
2969
3001
@_add_click_options (_TASK_OPTIONS + _EXTRA_RESOURCES_OPTIONS )
3002
+ @click .option ('--cpus' ,
3003
+ default = None ,
3004
+ type = str ,
3005
+ required = False ,
3006
+ help = ('Number of vCPUs each instance must have (e.g., '
3007
+ '``--cpus=4`` (exactly 4) or ``--cpus=4+`` (at least 4)). '
3008
+ 'This is used to automatically select the instance type.' ))
2970
3009
@click .option ('--spot-recovery' ,
2971
3010
default = None ,
2972
3011
type = str ,
@@ -3009,6 +3048,7 @@ def spot_launch(
3009
3048
region : Optional [str ],
3010
3049
zone : Optional [str ],
3011
3050
gpus : Optional [str ],
3051
+ cpus : Optional [str ],
3012
3052
instance_type : Optional [str ],
3013
3053
num_nodes : Optional [int ],
3014
3054
use_spot : Optional [bool ],
@@ -3047,6 +3087,7 @@ def spot_launch(
3047
3087
region = region ,
3048
3088
zone = zone ,
3049
3089
gpus = gpus ,
3090
+ cpus = cpus ,
3050
3091
instance_type = instance_type ,
3051
3092
num_nodes = num_nodes ,
3052
3093
use_spot = use_spot ,
0 commit comments