slicing

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReplicaGpuIdSeparator is the separator used to separate the GPU ID from the replica ID in the
	// GPU devices exposed by the NVIDIA device plugin as shared GPUs.
	ReplicaGpuIdSeparator = "::"
	// MinSliceMemoryGB is the smallest slice size that can be created on slicing shared GPUs.
	MinSliceMemoryGB = 1
)

Variables

This section is empty.

Functions

func AsResources

func AsResources(g gpu.Geometry) map[v1.ResourceName]int

func ExtractGpuId

func ExtractGpuId(resourceId string) string

ExtractGpuId returns the GPU ID corresponding to the resource ID provided as argument.

func ExtractProfileNameStr

func ExtractProfileNameStr(r v1.ResourceName) (string, error)

func GetRequestedProfiles

func GetRequestedProfiles(pod v1.Pod) map[ProfileName]int

func IsGpuSlice

func IsGpuSlice(r v1.ResourceName) bool

func NewClient

func NewClient(resourceClient resource.Client, nvmlClient nvml.Client) gpu.Client

Types

type GPU

type GPU struct {
	Model        gpu.Model
	Index        int
	MemoryGB     int
	UsedProfiles map[ProfileName]int
	FreeProfiles map[ProfileName]int
}

func NewFullGPU

func NewFullGPU(model gpu.Model, index int, memoryGB int) GPU

func NewGPU

func NewGPU(model gpu.Model, index int, memoryGB int, usedProfiles, freeProfiles map[ProfileName]int) (GPU, error)

func NewGpuOrPanic

func NewGpuOrPanic(model gpu.Model, index int, memoryGB int, usedProfiles, freeProfiles map[ProfileName]int) GPU

func (*GPU) AddPod

func (g *GPU) AddPod(pod v1.Pod) error

AddPod adds a Pod to the GPU by updating the free and used slices according to the ones requested by the Pod.

AddPod returns an error if the GPU does not have enough free slices for the Pod.

func (*GPU) Clone

func (g *GPU) Clone() GPU

func (*GPU) GetGeometry

func (g *GPU) GetGeometry() gpu.Geometry

func (*GPU) HasFreeCapacity

func (g *GPU) HasFreeCapacity() bool

func (*GPU) UpdateGeometryFor

func (g *GPU) UpdateGeometryFor(slices map[gpu.Slice]int) bool

UpdateGeometryFor tries to update the geometry of the GPU in order to create the highest possible number of required slices provided as argument, without deleting any of the used slices.

The method returns true if the GPU geometry gets updated, false otherwise.

func (*GPU) Validate

func (g *GPU) Validate() error

type Node

type Node struct {
	Name string
	GPUs []GPU
	// contains filtered or unexported fields
}

func NewNode

func NewNode(n framework.NodeInfo) (Node, error)

func (*Node) AddPod

func (n *Node) AddPod(pod v1.Pod) error

AddPod adds a Pod to the node by updating the free and used slices of the Node GPUs according to the slices requested by the Pod.

AddPod returns an error if the node does not have any GPU providing enough free slices resources for the Pod.

func (*Node) Clone

func (n *Node) Clone() interface{}

func (*Node) Geometry

func (n *Node) Geometry() map[gpu.Slice]int

Geometry returns the overall geometry of the node, which corresponds to the sum of the geometries of all the GPUs present in the Node.

func (*Node) GetName

func (n *Node) GetName() string

func (*Node) HasFreeCapacity

func (n *Node) HasFreeCapacity() bool

HasFreeCapacity returns true if any of the GPUs of the node has enough free capacity for hosting more pods.

func (*Node) NodeInfo

func (n *Node) NodeInfo() framework.NodeInfo

func (*Node) UpdateGeometryFor

func (n *Node) UpdateGeometryFor(slices map[gpu.Slice]int) (bool, error)

type ProfileName

type ProfileName string

func ExtractProfileName

func ExtractProfileName(resourceName v1.ResourceName) (ProfileName, error)

ExtractProfileName extracts the name of the slicing profile from the provided resource name, and returns an error if the resource name is not a valid NVIDIA slicing resource.

Example:

nvidia.com/10gb => 10gb
nvidia.com/gpu => error

func NewProfile

func NewProfile(sizeGb int) ProfileName

func (ProfileName) AsResourceName

func (p ProfileName) AsResourceName() v1.ResourceName

func (ProfileName) GetMemorySizeGB

func (p ProfileName) GetMemorySizeGB() int

func (ProfileName) SmallerThan

func (p ProfileName) SmallerThan(other gpu.Slice) bool

func (ProfileName) String

func (p ProfileName) String() string

Jump to

Keyboard shortcuts

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