-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: SeungAh Lee <seungah.lee@friendli.ai> Co-authored-by: Sungwoo Cho <swcho@friendli.ai>
- Loading branch information
1 parent
b53f356
commit 0ef04d3
Showing
14 changed files
with
171 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/docs/cli/vm/_category_.json → docs/docs/cli/gpu/_category_.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"label": "pf vm", | ||
"label": "pf gpu", | ||
"collapsible": true, | ||
"collapsed": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# pf gpu list | ||
|
||
## Usage | ||
|
||
```bash | ||
pf gpu list | ||
``` | ||
|
||
## Summary | ||
|
||
List up available GPUs. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright (c) 2022-present, FriendliAI Inc. All rights reserved. | ||
|
||
"""PeriFlow GPU CLI.""" | ||
|
||
from __future__ import annotations | ||
|
||
import typer | ||
|
||
from periflow.client.deployment import PFSVMClient | ||
from periflow.enums import GpuType | ||
from periflow.formatter import TableFormatter | ||
|
||
app = typer.Typer( | ||
no_args_is_help=True, | ||
context_settings={"help_option_names": ["-h", "--help"]}, | ||
add_completion=False, | ||
) | ||
|
||
serving_gpu_formatter = TableFormatter( | ||
name="Serving GPU instances", | ||
fields=[ | ||
"cloud", | ||
"region", | ||
"gpu_type", | ||
"supported_num_gpus", | ||
], | ||
headers=[ | ||
"Cloud", | ||
"Region", | ||
"GPU type", | ||
"Supported #GPUs", | ||
], | ||
) | ||
|
||
|
||
# pylint: disable=redefined-builtin | ||
@app.command() | ||
def list(): | ||
"""List up available GPUs.""" | ||
pfs_vm_client = PFSVMClient() | ||
response = pfs_vm_client.list_vms() | ||
vm_dict = {} | ||
|
||
def _gpu_key(nodegroup_list_dict, nodegroup) -> str: | ||
return f'{nodegroup_list_dict["cloud"].upper()}-{nodegroup_list_dict["region"]}\ | ||
-{nodegroup["vm"]["gpu_type"].upper()}' | ||
|
||
for nodegroup_list_dict in response: | ||
for nodegroup in nodegroup_list_dict["nodegroup_list"]: | ||
if nodegroup["vm"]["gpu_type"] in [gpu_type.value for gpu_type in GpuType]: | ||
gpu_key = _gpu_key(nodegroup_list_dict, nodegroup) | ||
if gpu_key in vm_dict: | ||
vm_dict[gpu_key][ | ||
"supported_num_gpus" | ||
] += f', {nodegroup["vm"]["total_gpus"]}' | ||
else: | ||
vm_dict[gpu_key] = { | ||
"cloud": nodegroup_list_dict["cloud"].upper(), | ||
"region": nodegroup_list_dict["region"], | ||
"vm": nodegroup["vm"], | ||
"gpu_type": nodegroup["vm"]["gpu_type"].upper(), | ||
"supported_num_gpus": str(nodegroup["vm"]["total_gpus"]), | ||
} | ||
|
||
serving_gpu_formatter.render(vm_dict.values()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.