Files
2025-08-25 16:04:00 +08:00

31 lines
522 B
Go

package utils
import "k8s.io/api/core/v1"
// Is the Node for GPU sharing
func IsGPUSharingNode(node *v1.Node) bool {
return GetTotalGPUMemory(node) > 0
}
// Get the total GPU memory of the Node
func GetTotalGPUMemory(node *v1.Node) int {
val, ok := node.Status.Capacity[ResourceName]
if !ok {
return 0
}
return int(val.Value())
}
// Get the GPU count of the node
func GetGPUCountInNode(node *v1.Node) int {
val, ok := node.Status.Capacity[CountName]
if !ok {
return int(0)
}
return int(val.Value())
}