device

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// AttributeMediaExtensions holds the string representation for the media extension MIG profile attribute.
	AttributeMediaExtensions = "me"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device interface {
	nvml.Device
	GetArchitectureAsString() (string, error)
	GetBrandAsString() (string, error)
	GetCudaComputeCapabilityAsString() (string, error)
	GetMigDevices() ([]MigDevice, error)
	GetMigProfiles() ([]MigProfile, error)
	IsMigCapable() (bool, error)
	IsMigEnabled() (bool, error)
	VisitMigDevices(func(j int, m MigDevice) error) error
	VisitMigProfiles(func(p MigProfile) error) error
}

Device defines the set of extended functions associated with a device.Device.

type Identifier

type Identifier string

Identifier can be used to refer to a GPU or MIG device. This includes a device index or UUID.

func (Identifier) IsGpuIndex

func (i Identifier) IsGpuIndex() bool

IsGpuIndex checks if an identifier is a full GPU index.

func (Identifier) IsGpuUUID

func (i Identifier) IsGpuUUID() bool

IsGpuUUID checks if an identifier is a GPU UUID. A GPU UUID must be of the form GPU-b1028956-cfa2-0990-bf4a-5da9abb51763.

func (Identifier) IsMigIndex

func (i Identifier) IsMigIndex() bool

IsMigIndex checks if an identifier is a MIG index.

func (Identifier) IsMigUUID

func (i Identifier) IsMigUUID() bool

IsMigUUID checks if an identifier is a MIG UUID. A MIG UUID can be of one of two forms:

  • MIG-b1028956-cfa2-0990-bf4a-5da9abb51763
  • MIG-GPU-b1028956-cfa2-0990-bf4a-5da9abb51763/3/0

func (Identifier) IsUUID

func (i Identifier) IsUUID() bool

IsUUID checks if an identifier is a UUID.

type Interface

type Interface interface {
	AssertValidMigProfileFormat(profile string) error
	GetDevices() ([]Device, error)
	GetMigDevices() ([]MigDevice, error)
	GetMigProfiles() ([]MigProfile, error)
	NewDevice(d nvml.Device) (Device, error)
	NewDeviceByUUID(uuid string) (Device, error)
	NewMigDevice(d nvml.Device) (MigDevice, error)
	NewMigDeviceByUUID(uuid string) (MigDevice, error)
	NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, migMemorySizeMB, deviceMemorySizeBytes uint64) (MigProfile, error)
	ParseMigProfile(profile string) (MigProfile, error)
	VisitDevices(func(i int, d Device) error) error
	VisitMigDevices(func(i int, d Device, j int, m MigDevice) error) error
	VisitMigProfiles(func(p MigProfile) error) error
}

Interface provides the API to the 'device' package.

func New

func New(opts ...Option) Interface

New creates a new instance of the 'device' interface.

type MigDevice

type MigDevice interface {
	nvml.Device
	GetProfile() (MigProfile, error)
}

MigDevice defines the set of extended functions associated with a MIG device.

type MigProfile

type MigProfile interface {
	String() string
	GetInfo() MigProfileInfo
	Equals(other MigProfile) bool
	Matches(profile string) bool
}

MigProfile represents a specific MIG profile. Examples include "1g.5gb", "2g.10gb", "1c.2g.10gb", or "1c.1g.5gb+me", etc.

type MigProfileInfo

type MigProfileInfo struct {
	C              int
	G              int
	GB             int
	Attributes     []string
	GIProfileID    int
	CIProfileID    int
	CIEngProfileID int
}

MigProfileInfo holds all info associated with a specific MIG profile.

func (MigProfileInfo) Equals

func (p MigProfileInfo) Equals(other MigProfile) bool

Equals checks if two Profiles are identical or not.

func (MigProfileInfo) GetInfo

func (p MigProfileInfo) GetInfo() MigProfileInfo

GetInfo returns detailed info about a Profile.

func (MigProfileInfo) Matches

func (p MigProfileInfo) Matches(profile string) bool

Matches checks if a MigProfile matches the string passed in.

func (MigProfileInfo) String

func (p MigProfileInfo) String() string

String returns the string representation of a Profile.

type Option

type Option func(*devicelib)

Option defines a function for passing options to the New() call.

func WithNvml

func WithNvml(nvml nvml.Interface) Option

WithNvml provides an Option to set the NVML library used by the 'device' interface.

func WithSkippedDevices

func WithSkippedDevices(names ...string) Option

WithSkippedDevices provides an Option to set devices to be skipped by model name.

func WithVerifySymbols

func WithVerifySymbols(verify bool) Option

WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them.

Jump to

Keyboard shortcuts

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