Based on your query, I'll assume you're working with a Kubernetes (K8s) cluster where GPU nodes are configured (e.g., using NVIDIA GPUs, which is the most common setup). In Kubernetes, GPUs are exposed as a schedulable resource via a device plugin (like the NVIDIA GPU device plugin). The resource is typically named nvidia.com/gpu (for NVIDIA) or something similar for other vendors like AMD (amd.com/gpu).
I'll walk you through how to check the GPU capacity of a node step by step. This will give you the number of GPUs available on the node (e.g., 1, 2, 4, etc.). If you need more granular details like GPU model, memory, or utilization, I'll cover that too.
Prerequisites
- You have
kubectl installed and configured to access your Kubernetes cluster.
- Your cluster has GPU nodes set up with the appropriate device plugin (e.g., NVIDIA's k8s-device-plugin daemonset).
- If your GPUs aren't showing up, ensure the device plugin is installed and running (e.g., via
kubectl get daemonset -n kube-system).
Step 1: List All Nodes in Your Cluster
First, identify the GPU-enabled nodes. GPU nodes often have labels like accelerator=nvidia or similar.
kubectl get nodes -o wide
- Look for nodes with GPU-related labels or taints (e.g., in the "LABELS" column).
- Note the name of the GPU node (e.g.,
gke-gpu-node-1).
You can filter for GPU nodes if they have a specific label:
kubectl get nodes -l 'beta.kubernetes.io/instance-type=gpu' # Adjust label as needed
Step 2: Describe the Node to View GPU Capacity
Use kubectl describe to inspect the node's resources. The GPU capacity will appear under the "Capacity" section as nvidia.com/gpu: <number> (e.g., nvidia.com/gpu: 2 means 2 GPUs).
kubectl describe node <node-name> # Replace <node-name> with the actual name, e.g., gke-gpu-node-1
Example output snippet (focus on the "Capacity" and "Allocatable" sections):
Name: gke-gpu-node-1
Roles: <none>
Labels: beta.kubernetes.io/instance-type=n1-standard-8
nvidia.com/gpu=true
...
Capacity:
cpu: 8
ephemeral-storage: 100Gi
hugepages-1Gi: 0
memory: 32768Mi
nvidia.com/gpu: 2 # This is the GPU capacity (2 GPUs on this node)
pods: 110
Allocatable:
cpu: 8
ephemeral-storage: 100Gi
hugepages-1Gi: 0
memory: 32768Mi
nvidia.com/gpu: 2 # Allocatable GPUs (may be less if some are reserved)
pods: 110
...
- Capacity: Total GPUs available on the node.
- Allocatable: GPUs available for scheduling (after subtracting any reserved resources).
- If you don't see
nvidia.com/gpu (or equivalent), the device plugin isn't installed or the node doesn't have GPUs detected.
For AMD GPUs, look for amd.com/gpu instead.
Step 3: Get GPU Capacity Across All Nodes (Scriptable)
If you want a quick overview of GPU capacity for all nodes:
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.nvidia\.com/gpu}{"\n"}{end}'
Step 4: Check GPU Allocation and Usage
Getting More Detailed GPU Info (Beyond Capacity)
Kubernetes itself only tracks the count of GPUs as a resource. For deeper details (e.g., GPU model, VRAM, utilization, temperature):
Troubleshooting
- No GPU Capacity Shown?
- Ensure the NVIDIA device plugin is running:
kubectl get ds -n kube-system nvidia-device-plugin-daemonset.
- Check node logs:
kubectl logs -n kube-system -l name=nvidia-device-plugin-ds.
- Verify NVIDIA drivers are installed on the host (run
nvidia-smi on the server).
- If using cloud providers (GKE, EKS, AKS), ensure GPU instance types are used and the cluster addon is enabled.
- Custom GPU Resource Names: If your setup uses a different name (e.g., for MIG-enabled GPUs like
nvidia.com/mig-1g.5gb), adjust accordingly in commands.
- Multi-Instance GPUs (MIG): NVIDIA A100+ supports partitioning one GPU into multiple instances. Capacity might show as multiple smaller units.
- Permissions: You need cluster-admin or equivalent access for these commands.
If this doesn't match your setup (e.g., non-NVIDIA GPUs, specific cloud provider, or error messages), provide more details for tailored advice!