nvcdi

package
v1.18.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 26 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// AllHooks is a special hook name that allows all hooks to be matched.
	AllHooks = discover.AllHooks

	// A CreateSymlinksHook is used to create symlinks in the container.
	CreateSymlinksHook = discover.CreateSymlinksHook
	// DisableDeviceNodeModificationHook refers to the hook used to ensure that
	// device nodes are not created by libnvidia-ml.so or nvidia-smi in a
	// container.
	// Added in v1.17.8
	DisableDeviceNodeModificationHook = discover.DisableDeviceNodeModificationHook
	// An EnableCudaCompatHook is used to enabled CUDA Forward Compatibility.
	// Added in v1.17.5
	EnableCudaCompatHook = discover.EnableCudaCompatHook
	// An UpdateLDCacheHook is used to update the ldcache in the container.
	UpdateLDCacheHook = discover.UpdateLDCacheHook

	// Deprecated: Use CreateSymlinksHook instead.
	HookCreateSymlinks = CreateSymlinksHook
	// Deprecated: Use EnableCudaCompatHook instead.
	HookEnableCudaCompat = EnableCudaCompatHook
	// Deprecated: Use UpdateLDCacheHook instead.
	HookUpdateLDCache = UpdateLDCacheHook
)
View Source
const (
	// FeatureDisableNvsandboxUtils disables the use of nvsandboxutils when
	// querying devices.
	FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandbox-utils")
	// FeatureEnableCoherentAnnotations enables the addition of annotations
	// coherent or non-coherent devices.
	FeatureEnableCoherentAnnotations = FeatureFlag("enable-coherent-annotations")
)
View Source
const (
	// ModeAuto configures the CDI spec generator to automatically detect the system configuration
	ModeAuto = Mode("auto")
	// ModeNvml configures the CDI spec generator to use the NVML library.
	ModeNvml = Mode("nvml")
	// ModeWsl configures the CDI spec generator to generate a WSL spec.
	ModeWsl = Mode("wsl")
	// ModeManagement configures the CDI spec generator to generate a management spec.
	ModeManagement = Mode("management")
	// ModeGdrcopy configures the CDI spec generator to generate a GDR Copy spec.
	ModeGdrcopy = Mode("gdrcopy")
	// ModeGds configures the CDI spec generator to generate a GDS spec.
	ModeGds = Mode("gds")
	// ModeMofed configures the CDI spec generator to generate a MOFED spec.
	ModeMofed = Mode("mofed")
	// ModeCSV configures the CDI spec generator to generate a spec based on the contents of CSV
	// mountspec files.
	ModeCSV = Mode("csv")
	// ModeImex configures the CDI spec generator to generate a spec for the available IMEX channels.
	ModeImex = Mode("imex")
	// ModeNvswitch configures the CDI spec generator to generate a spec for the available nvswitch devices.
	ModeNvswitch = Mode("nvswitch")
)
View Source
const (
	// DeviceNameStrategyIndex generates devices names such as 0 or 1:0
	DeviceNameStrategyIndex = "index"
	// DeviceNameStrategyTypeIndex generates devices names such as gpu0 or mig1:0
	DeviceNameStrategyTypeIndex = "type-index"
	// DeviceNameStrategyUUID uses the device UUID as the name
	DeviceNameStrategyUUID = "uuid"
)

Supported device naming strategies

Variables

This section is empty.

Functions

func AllModes added in v1.18.0

func AllModes[T modeConstraint]() []T

AllModes returns the set of valid modes.

func IsValidMode added in v1.18.0

func IsValidMode[T modeConstraint](mode T) bool

IsValidMode checks whether a specified mode is valid.

func NewDriverBinariesDiscoverer

func NewDriverBinariesDiscoverer(logger logger.Interface, driverRoot string) discover.Discover

NewDriverBinariesDiscoverer creates a discoverer for GSP firmware associated with the GPU driver.

func NewDriverFirmwareDiscoverer

func NewDriverFirmwareDiscoverer(logger logger.Interface, driverRoot string, version string) (discover.Discover, error)

NewDriverFirmwareDiscoverer creates a discoverer for GSP firmware associated with the specified driver version.

Types

type DeviceNamer

type DeviceNamer interface {
	GetDeviceName(int, UUIDer) (string, error)
	GetMigDeviceName(int, UUIDer, int, UUIDer) (string, error)
}

DeviceNamer is an interface for getting device names

func NewDeviceNamer

func NewDeviceNamer(strategy string) (DeviceNamer, error)

NewDeviceNamer creates a Device Namer based on the supplied strategy. This namer can be used to construct the names for MIG and GPU devices when generating the CDI spec.

type DeviceNamers added in v1.15.0

type DeviceNamers []DeviceNamer

DeviceNamers represents a list of device namers

func (DeviceNamers) GetDeviceNames added in v1.15.0

func (l DeviceNamers) GetDeviceNames(i int, d UUIDer) ([]string, error)

func (DeviceNamers) GetMigDeviceNames added in v1.15.0

func (l DeviceNamers) GetMigDeviceNames(i int, d UUIDer, j int, mig UUIDer) ([]string, error)

type DeviceSpecGenerator added in v1.18.0

type DeviceSpecGenerator interface {
	GetDeviceSpecs() ([]specs.Device, error)
}

A DeviceSpecGenerator is used to generate the specs for one or more devices.

type DeviceSpecGenerators added in v1.18.0

type DeviceSpecGenerators []DeviceSpecGenerator

DeviceSpecGenerators can be used to combine multiple device spec generators. This type also implements the DeviceSpecGenerator interface.

func (DeviceSpecGenerators) GetDeviceSpecs added in v1.18.0

func (g DeviceSpecGenerators) GetDeviceSpecs() ([]specs.Device, error)

GetDeviceSpecs returns the combined specs for each device spec generator.

type FeatureFlag added in v1.18.0

type FeatureFlag string

A FeatureFlag refers to a specific feature that can be toggled in the CDI api. All features are off by default.

type HookName added in v1.17.5

type HookName = discover.HookName

A HookName represents one of the predefined NVIDIA CDI hooks.

type Interface

type Interface interface {
	SpecGenerator
	GetCommonEdits() (*cdi.ContainerEdits, error)
	GetDeviceSpecsByID(...string) ([]specs.Device, error)
	// Deprecated: GetAllDeviceSpecs is deprecated. Use GetDeviceSpecsByID("all") instead.
	GetAllDeviceSpecs() ([]specs.Device, error)
}

Interface defines the API for the nvcdi package

func New

func New(opts ...Option) (Interface, error)

New creates a new nvcdi library

type Mode added in v1.18.0

type Mode string

type Option

type Option func(*nvcdilib)

Option is a function that configures the nvcdilib

func WithCSVFiles added in v1.14.0

func WithCSVFiles(csvFiles []string) Option

WithCSVFiles sets the CSV files for the library

func WithCSVIgnorePatterns added in v1.14.2

func WithCSVIgnorePatterns(csvIgnorePatterns []string) Option

WithCSVIgnorePatterns sets the ignore patterns for entries in the CSV files.

func WithClass

func WithClass(class string) Option

WithClass sets the class for the library

func WithConfigSearchPaths added in v1.15.0

func WithConfigSearchPaths(paths []string) Option

WithConfigSearchPaths sets the search paths for config files.

func WithDevRoot added in v1.15.0

func WithDevRoot(root string) Option

WithDevRoot sets the root where /dev is located.

func WithDeviceLib

func WithDeviceLib(devicelib device.Interface) Option

WithDeviceLib sets the device library for the library

func WithDeviceNamers added in v1.15.0

func WithDeviceNamers(namers ...DeviceNamer) Option

WithDeviceNamers sets the device namer for the library

func WithDisabledHook deprecated added in v1.17.5

func WithDisabledHook[T string | HookName](hook T) Option

WithDisabledHook allows specific hooks to be disabled. This option can be specified multiple times for each hook.

Deprecated: Use WithDisabledHooks instead

func WithDisabledHooks added in v1.18.0

func WithDisabledHooks[T string | HookName](hooks ...T) Option

WithDisabledHooks allows specific hooks to be disabled.

func WithDriverRoot

func WithDriverRoot(root string) Option

WithDriverRoot sets the driver root for the library

func WithEnabledHooks added in v1.18.0

func WithEnabledHooks[T string | HookName](hooks ...T) Option

WithEnabledHooks explicitly enables a specific set of hooks. If a hook is explicitly enabled, this takes precedence over it being disabled.

func WithFeatureFlag deprecated added in v1.18.0

func WithFeatureFlag[T string | FeatureFlag](featureFlag T) Option

WithFeatureFlag allows specified features to be toggled on. This option can be specified multiple times for each feature flag.

Deprecated: Use WithFeatureFlags

func WithFeatureFlags added in v1.18.0

func WithFeatureFlags[T string | FeatureFlag](featureFlags ...T) Option

WithFeatureFlags allows the specified set of features to be toggled on.

func WithInfoLib added in v1.16.0

func WithInfoLib(infolib info.Interface) Option

WithInfoLib sets the info library for CDI spec generation.

func WithLdconfigPath added in v1.15.0

func WithLdconfigPath(path string) Option

WithLdconfigPath sets the path to the ldconfig program

func WithLibrarySearchPaths added in v1.14.0

func WithLibrarySearchPaths(paths []string) Option

WithLibrarySearchPaths sets the library search paths. This is currently only used for CSV-mode.

func WithLogger

func WithLogger(logger logger.Interface) Option

WithLogger sets the logger for the library

func WithMergedDeviceOptions added in v1.14.0

func WithMergedDeviceOptions(opts ...transform.MergedDeviceOption) Option

WithMergedDeviceOptions sets the merged device options for the library If these are not set, no merged device will be generated.

func WithMode

func WithMode[m modeConstraint](mode m) Option

WithMode sets the discovery mode for the library

func WithNVIDIACDIHookPath added in v1.16.0

func WithNVIDIACDIHookPath(path string) Option

WithNVIDIACDIHookPath sets the path to the NVIDIA Container Toolkit CLI path for the library

func WithNVIDIACTKPath deprecated

func WithNVIDIACTKPath(path string) Option

WithNVIDIACTKPath sets the path to the NVIDIA Container Toolkit CLI path for the library

Deprecated: Use WithNVIDIACDIHookPath instead.

func WithNvmlLib

func WithNvmlLib(nvmllib nvml.Interface) Option

WithNvmlLib sets the nvml library for the library

func WithVendor

func WithVendor(vendor string) Option

WithVendor sets the vendor for the library

type SpecGenerator added in v1.18.0

type SpecGenerator interface {
	GetSpec(...string) (spec.Interface, error)
}

A SpecGenerator is used to generate a complete CDI spec for a collected set of devices.

type UUIDer added in v1.14.0

type UUIDer interface {
	GetUUID() (string, error)
}

UUIDer is an interface for getting UUIDs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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