sharecfg

package
v0.0.0-...-91ab7b7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MB uint64 = 1024 * 1024

MB - 1 megabyte.

Variables

View Source
var ErrNegativeSharesCount = errors.New("MortalGPU shares count is negative")

Functions

func IsManagedDevice

func IsManagedDevice(devCfg *DeviceSharingConfig, devUuid, modelName string, migId int) bool

IsManagedDevice checks if the given device has sharing configuration.

Types

type DeviceSharingConfig

type DeviceSharingConfig struct {
	// Uuid - NVIDIA device UUID.
	Uuid []string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
	// Model - human readable GPU model name
	// used for selecting GPUs to handle.
	// If Uuid is set, then Model is ignored.
	ModelName []string `json:"modelName,omitempty" yaml:"modelName,omitempty"`
	// Migid - MIG device id.
	Migid []int `json:"migid,omitempty" yaml:"migid,omitempty"`
	// ResourceName - Kubernetes resource name to handle.
	ResourceName string `json:"resourceName,omitempty" yaml:"resourceName,omitempty"`
	// MetagpusPerGpu - number of meta GPUs to split the GPU on.
	MetagpusPerGpu uint64 `json:"metagpusPerGpu,omitempty" yaml:"metagpusPerGpu,omitempty"`
	// MetagpusPerGpuMemoryChunkMB - GPU memory chunk size to
	// split the GPU to meta GPUs with the MetagpusPerGpuMemoryChunkMB
	// memory sizes.
	MetagpusPerGpuMemoryChunkMB uint64 `json:"metagpusPerGpuMemoryChunkMB,omitempty" yaml:"metagpusPerGpuMemoryChunkMB,omitempty"` //nolint:lll // Struct tags.
	// ReservedChunks - number of MortalGPU chunks which will be excluded from
	// allocation so that they can be used by other workloads.
	ReservedChunks uint64 `json:"reservedChunks,omitempty" yaml:"reservedChunks,omitempty"`
}

func (*DeviceSharingConfig) ComputeSharesInfo

func (d *DeviceSharingConfig) ComputeSharesInfo(totalMemory uint64) (SharesInfo, error)

ComputeSharesInfo computes shares info based on the sharing configuration and total device memory.

func (*DeviceSharingConfig) MarshalLogObject

func (d *DeviceSharingConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject - implements zap.ObjectLogMarshaler.

type DevicesSharingConfigs

type DevicesSharingConfigs struct {
	Configs []*DeviceSharingConfig
	// contains filtered or unexported fields
}

func NewDeviceSharingConfig

func NewDeviceSharingConfig(logger *zap.Logger, cfg []*DeviceSharingConfig) *DevicesSharingConfigs

func (*DevicesSharingConfigs) GetDeviceSharingConfig

func (c *DevicesSharingConfigs) GetDeviceSharingConfig(devUuid, modelName string, migId int) (*DeviceSharingConfig, error)

type SharedDevice

type SharedDevice struct {
	// UUID shared device UUID (or MIG UUID).
	UUID string `json:"uuid,omitempty" yaml:"uuid"`
	// Index shared device index.
	Index int `json:"index,omitempty" yaml:"index"`
	// Shares extra information about the device.
	Shares SharesInfo `json:"shares,omitempty" yaml:"shares"`
}

SharedDevice a physical GPU (or a MIG partition) which is shared between containers.

func (*SharedDevice) ComputeMemFromShares

func (sd *SharedDevice) ComputeMemFromShares(sharesCount int) uint64

ComputeMemFromShares returns how much GPU RAM is the given number of shares represent.

func (*SharedDevice) Copy

func (sd *SharedDevice) Copy() *SharedDevice

Copy returns a copy of the data.

func (*SharedDevice) MarshalLogObject

func (sd *SharedDevice) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject - implements zap.ObjectLogMarshaler.

type SharesInfo

type SharesInfo struct {
	// ShareSize size of one share in memory bytes.
	ShareSize uint64
	// SharesCount number of shares.
	SharesCount uint64
}

SharesInfo contains information about how a GPU device is supposed to be split.

func (*SharesInfo) Copy

func (si *SharesInfo) Copy() *SharesInfo

Copy returns a copy of the data.

func (*SharesInfo) MarshalLogObject

func (si *SharesInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject - implements zap.ObjectLogMarshaler.

Jump to

Keyboard shortcuts

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