gpu

package
v0.0.0-...-12e0a72 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFoundErr = errorImpl{/* contains filtered or unexported fields */}
	GenericErr  = errorImpl{/* contains filtered or unexported fields */}
)

Functions

func GetCount

func GetCount(node v1.Node) (int, error)

GetCount returns the number of GPUs on the node.

func GetMemoryGB

func GetMemoryGB(node v1.Node) (int, error)

GetMemoryGB returns the amount of memory GB of the GPUs on the node.

func IsMigPartitioningEnabled

func IsMigPartitioningEnabled(node v1.Node) bool

IsMigPartitioningEnabled returns true if the node is enabled for automatic MIG GPU partitioning, false otherwise

func IsMpsPartitioningEnabled

func IsMpsPartitioningEnabled(node v1.Node) bool

IsMpsPartitioningEnabled returns true if the node is enabled for automatic MPS GPU partitioning, false otherwise

func IsNotFound

func IsNotFound(err error) bool

func ParseNodeAnnotations

func ParseNodeAnnotations(node v1.Node) (StatusAnnotationList, SpecAnnotationList)

Types

type Client

type Client interface {
	GetDevices(ctx context.Context) (DeviceList, Error)

	GetUsedDevices(ctx context.Context) (DeviceList, Error)

	GetAllocatableDevices(ctx context.Context) (DeviceList, Error)
}

type Device

type Device struct {
	resource.Device
	GpuIndex int
}

func ComputeFreeDevicesAndUpdateStatus

func ComputeFreeDevicesAndUpdateStatus(used []Device, allocatable []Device) []Device

func (Device) FullResourceName

func (m Device) FullResourceName() string

FullResourceName returns the full resource name of the MIG device, including the name of the resource corresponding to the MIG profile and the index of the GPU to which it belongs to.

func (Device) String

func (m Device) String() string

type DeviceList

type DeviceList []Device

func (DeviceList) AsStatusAnnotation

func (l DeviceList) AsStatusAnnotation(getProfile extractProfileName) StatusAnnotationList

func (DeviceList) GetFree

func (l DeviceList) GetFree() DeviceList

func (DeviceList) GetUsed

func (l DeviceList) GetUsed() DeviceList

func (DeviceList) GroupBy

func (l DeviceList) GroupBy(keyFunc func(resource Device) string) map[string]DeviceList

func (DeviceList) GroupByGpuIndex

func (l DeviceList) GroupByGpuIndex() map[int]DeviceList

func (DeviceList) GroupByResourceName

func (l DeviceList) GroupByResourceName() map[v1.ResourceName]DeviceList

func (DeviceList) GroupByStatus

func (l DeviceList) GroupByStatus() map[resource.Status]DeviceList

func (DeviceList) SortByDeviceId

func (l DeviceList) SortByDeviceId() DeviceList

type DevicePluginClient

type DevicePluginClient interface {
	// Restart restarts the NVIDIA device plugin pod on the specified node, waiting until the
	// pod is again in state "Running" or the timeout is reached.
	Restart(ctx context.Context, nodeName string, timeout time.Duration) error
}

func NewDevicePluginClient

func NewDevicePluginClient(k8sClient client.Client) DevicePluginClient

type Error

type Error interface {
	error
	IsNotFound() bool
}

func IgnoreNotFound

func IgnoreNotFound(err Error) Error

func NewGenericError

func NewGenericError(err error) Error

type ErrorList

type ErrorList []Error

func (ErrorList) Error

func (l ErrorList) Error() string

type Geometry

type Geometry map[Slice]int

Geometry corresponds to the partitioning Geometry of a GPU, namely the slices of the GPU with the respective quantity.

func GetFewestSlicesGeometry

func GetFewestSlicesGeometry(geometries []Geometry) Geometry

GetFewestSlicesGeometry returns the geometry with the lowest number of different slices

func (Geometry) Id

func (g Geometry) Id() string

func (Geometry) MarshalJSON

func (g Geometry) MarshalJSON() ([]byte, error)

func (Geometry) String

func (g Geometry) String() string

type Model

type Model string
const (
	GPUModel_A30            Model = "A30"
	GPUModel_A100_SXM4_40GB Model = "NVIDIA-A100-40GB-SXM4"
	GPUModel_A100_PCIe_80GB Model = "NVIDIA-A100-80GB-PCIe"
)

func GetModel

func GetModel(node v1.Node) (Model, error)

GetModel returns the model of the GPUs on the node. It is assumed that all the GPUs of the node are of the same model.

func (Model) String

func (m Model) String() string

type PartitioningKind

type PartitioningKind string
const (
	PartitioningKindMig    PartitioningKind = "mig"
	PartitioningKindMps    PartitioningKind = "mps"
	PartitioningKindHybrid PartitioningKind = "hybrid"
)

func GetPartitioningKind

func GetPartitioningKind(node v1.Node) (PartitioningKind, bool)

func (PartitioningKind) String

func (p PartitioningKind) String() string

type Slice

type Slice interface {
	SmallerThan(other Slice) bool
	String() string
}

type SliceCalculator

type SliceCalculator interface {
	GetRequestedSlices(pod v1.Pod) map[Slice]int
}

type SliceFilter

type SliceFilter interface {
	ExtractSlices(resources map[v1.ResourceName]int64) map[Slice]int
}

type SpecAnnotation

type SpecAnnotation struct {
	ProfileName string
	Index       int
	Quantity    int
}

func ParseSpecAnnotation

func ParseSpecAnnotation(key, value string) (SpecAnnotation, error)

func (SpecAnnotation) GetIndexWithProfile

func (a SpecAnnotation) GetIndexWithProfile() string

GetIndexWithProfile returns the GPU index included in the annotation together with the respective profile. Example:

Annotation:

"nos.nebuly.com/status-gpu-0-1g.10gb-used"

Result:

"0-1g.10gb"

func (SpecAnnotation) GetValue

func (a SpecAnnotation) GetValue() string

func (SpecAnnotation) String

func (a SpecAnnotation) String() string

type SpecAnnotationList

type SpecAnnotationList []SpecAnnotation

func (SpecAnnotationList) GroupByGpuIndex

func (l SpecAnnotationList) GroupByGpuIndex() map[int]SpecAnnotationList

type StatusAnnotation

type StatusAnnotation struct {
	ProfileName string
	Index       int
	Status      resource.Status
	Quantity    int
}

func ParseStatusAnnotation

func ParseStatusAnnotation(key, value string) (StatusAnnotation, error)

func (StatusAnnotation) GetIndexWithProfile

func (a StatusAnnotation) GetIndexWithProfile() string

GetIndexWithProfile returns the GPU index included in the annotation together with the respective profile. Example:

Annotation:

"nos.nebuly.com/status-gpu-0-1g.10gb-used"

Result:

"0-1g.10gb"

func (StatusAnnotation) GetValue

func (a StatusAnnotation) GetValue() string

func (StatusAnnotation) IsFree

func (a StatusAnnotation) IsFree() bool

IsFree returns true if the annotation refers to a free device

func (StatusAnnotation) IsUsed

func (a StatusAnnotation) IsUsed() bool

IsUsed returns true if the annotation refers to a used device

func (StatusAnnotation) String

func (a StatusAnnotation) String() string

type StatusAnnotationList

type StatusAnnotationList []StatusAnnotation

func (StatusAnnotationList) Equal

func (StatusAnnotationList) Filter

func (l StatusAnnotationList) Filter(keep func(annotation StatusAnnotation) bool) StatusAnnotationList

func (StatusAnnotationList) GetFree

GetFree return a new GPUStatusAnnotationList containing the annotations referring to free devices

func (StatusAnnotationList) GetUsed

GetUsed return a new GPUStatusAnnotationList containing the annotations referring to used devices

func (StatusAnnotationList) GroupByGpuIndex

func (l StatusAnnotationList) GroupByGpuIndex() map[int]StatusAnnotationList

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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