Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[k8s] Show per node status in sky show-gpus #3816

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

romilbhardwaj
Copy link
Collaborator

@romilbhardwaj romilbhardwaj commented Aug 8, 2024

Updates sky show-gpus --cloud kubernetes to also show per node GPU availability information. Helps users debug out of resource errors and get better visibility into their cluster.

Example:

$ sky show-gpus --cloud kubernetes
Kubernetes GPUs
GPU   QTY_PER_NODE  TOTAL_GPUS  TOTAL_FREE_GPUS
T4    1             4           3
V100  1, 2          4           1

Kubernetes per node GPU availability
NODE_NAME                               GPU_NAME  TOTAL_GPUS  FREE_GPUS
gke-gkeusc5-default-pool-93c7cbf8-6ll6  T4        1           1
gke-gkeusc5-default-pool-93c7cbf8-czx8  T4        1           1
gke-gkeusc5-default-pool-93c7cbf8-fdhf  T4        1           0
gke-gkeusc5-default-pool-93c7cbf8-mfj8  T4        1           1
gke-gkeusc5-v100-570bede1-kwsf          V100      2           1
gke-gkeusc5-v100-570bede1-s23r          V100      2           0
gke-gkeusc5-largecpu-4fa50bdc-g7hr      None      0           0
gke-gkeusc5-largecpu-4fa50bdc-qqxq      None      0           0

Tested (run the relevant ones):

  • Code formatting: bash format.sh

Manual tests:

  • GKE cluster with different GPU types
  • GKE cluster with different GPU types and all GPUs utilized
  • Kind cluster without any GPUs

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @romilbhardwaj! LGTM.

Comment on lines +1702 to +1712
for pod in pods:
# Get all the pods running on the node
if (pod.spec.node_name == node.metadata.name and
pod.status.phase in ['Running', 'Pending']):
# Iterate over all the containers in the pod and sum the
# GPU requests
for container in pod.spec.containers:
if container.resources.requests:
allocated_qty += int(
container.resources.requests.get(
'nvidia.com/gpu', 0))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it might be interesting to show the number of running pods on each nodes as well, but this is minor if a user does not request that. : )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - though one challenge is a node may be running many pods across different namespaces.. perhaps we can show only the pods in the user's configured namespace. We can add this if users ask :)

@romilbhardwaj romilbhardwaj added this pull request to the merge queue Aug 8, 2024
Merged via the queue into master with commit 7f64d60 Aug 8, 2024
20 checks passed
@romilbhardwaj romilbhardwaj deleted the k8s_show_gpus_nodes branch August 8, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants