utils

package
v0.0.0-...-f2569be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceName = "alibabacloud.com/gpu-milli"      // GPU milli, i.e., 1000 == 1 GPU, for pod only, node is 1000 by default
	CountName    = "alibabacloud.com/gpu-count"      // GPU number request (or allocatable), for pod and node
	DeviceIndex  = "alibabacloud.com/gpu-index"      // Exists when the pod are assigned/predefined to a GPU device
	ModelName    = "alibabacloud.com/gpu-card-model" // GPU card model, for pod and node
	AssumeTime   = "alibabacloud.com/assume-time"    // To retrieve the scheduling latency
	CreationTime = "alibabacloud.com/creation-time"  // creation timestamp
	DeletionTime = "alibabacloud.com/deletion-time"  // deletion timestamp
	PodNsNameSep = "/"
	DevIdSep     = "-"
	MILLI        = 1000

	MaxSpecCpu  = 128000  // CPU MILLI
	MaxSpecMem  = 1048576 // Mem MiB
	MaxSpecGpu  = 8000    // GPU MILLI
	NoGpuTag    = "no-gpu"
	ShareGpuTag = "share-gpu"
)

Variables

View Source
var MapGpuTypeMemoryMiB = map[string]int64{
	"P4":      int64(7980711936 / 1024 / 1024),
	"2080":    int64(11554258944 / 1024 / 1024),
	"1080":    int64(11720982528 / 1024 / 1024),
	"M40":     int64(12004098048 / 1024 / 1024),
	"T4":      int64(15842934784 / 1024 / 1024),
	"V100M16": int64(16944988160 / 1024 / 1024),
	"P100":    int64(17070817280 / 1024 / 1024),
	"A10":     int64(23835181056 / 1024 / 1024),
	"3090":    int64(25446842368 / 1024 / 1024),
	"V100M32": int64(34089205760 / 1024 / 1024),
	"A100":    int64(85198045184 / 1024 / 1024),
	"G1":      int64(1048576000 / 1024 / 1024),
	"G2":      int64(20971520000 / 1024 / 1024),
	"G3":      int64(31457280000 / 1024 / 1024),
}

Functions

func AssignedNonTerminatedPod

func AssignedNonTerminatedPod(pod *v1.Pod) bool

AssignedNonTerminatedPod selects pods that are assigned and non-terminal (scheduled and running).

func GeneratePodKey

func GeneratePodKey(pod *v1.Pod) string

func GeneratePodKeyByName

func GeneratePodKeyByName(namespace, name string) string

func GetCreationTimeFromPodAnnotation

func GetCreationTimeFromPodAnnotation(p *v1.Pod) (t *time.Time)

func GetDeletionTimeFromPodAnnotation

func GetDeletionTimeFromPodAnnotation(p *v1.Pod) (t *time.Time)

func GetGpuAffinityFromPodAnnotation

func GetGpuAffinityFromPodAnnotation(p *v1.Pod) (affinity string)

GetGpuAffinityFromPodAnnotation returns the gpu affinity of the pod

func GetGpuCountFromPodAnnotation

func GetGpuCountFromPodAnnotation(pod *v1.Pod) (gpuCount int)

GetGpuCountFromPodAnnotation gets the GPU Count of the pod

func GetGpuCountOfNode

func GetGpuCountOfNode(node *v1.Node) int

GetGpuCountOfNode Get the GPU count of the node

func GetGpuIdFromAnnotation

func GetGpuIdFromAnnotation(pod *v1.Pod) (id string)

GetGpuIdFromAnnotation gets GPU ID from Annotation, could be "1" or "0-1-2-3" for multi-GPU allocations

func GetGpuIdListFromAnnotation

func GetGpuIdListFromAnnotation(pod *v1.Pod) (idl []int, err error)

GetGpuIdListFromAnnotation gets GPU ID List from Annotation, could be [1] or [0, 1, 2, 3] for multi-GPU allocations

func GetGpuMilliFromPodAnnotation

func GetGpuMilliFromPodAnnotation(pod *v1.Pod) (gpuMilli int64)

GetGpuMilliFromPodAnnotation gets the GPU (in Milli) of the pod, range: 0-1000

func GetGpuMilliOfNode

func GetGpuMilliOfNode(node *v1.Node) int

GetGpuMilliOfNode Get the GPU Milli of the node (0-8000 at most)

func GetGpuModelFromPodAnnotation

func GetGpuModelFromPodAnnotation(pod *v1.Pod) (gpuType string)

func GetGpuModelOfNode

func GetGpuModelOfNode(node *v1.Node) string

GetGpuModelOfNode Get the GPU Model of the node, see MapGpuTypeMemoryMiB

func GpuIdStrToIntList

func GpuIdStrToIntList(id string) (idl []int, err error)

GpuIdStrToIntList follows the string formed in func (n *GpuNodeInfo) AllocateGpuId

func IsCompletePod

func IsCompletePod(pod *v1.Pod) bool

IsCompletePod determines if the pod is complete

func IsGpuSharingNode

func IsGpuSharingNode(node *v1.Node) bool

IsGpuSharingNode Is the Node for GPU sharing

func RemovePodDeviceAnnoSpec

func RemovePodDeviceAnnoSpec(oldPod *v1.Pod) (newPod *v1.Pod)

func UpdatePodDeviceAnnoSpec

func UpdatePodDeviceAnnoSpec(oldPod *v1.Pod, devId string) (newPod *v1.Pod)

UpdatePodDeviceAnnoSpec updates pod env with devId

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL