Documentation
¶
Index ¶
- Constants
- Variables
- func IsPrivileged(s CapabilitiesGetter) bool
- type CUDA
- func (i CUDA) GetDriverCapabilities() DriverCapabilities
- func (i CUDA) GetRequirements() ([]string, error)
- func (i CUDA) Getenv(key string) string
- func (i CUDA) HasDisableRequire() bool
- func (i CUDA) HasEnvvar(key string) bool
- func (i CUDA) ImexChannelsFromEnvVar() []string
- func (i CUDA) ImexChannelsFromMounts() []string
- func (i CUDA) IsLegacy() bool
- func (i CUDA) IsPrivileged() bool
- func (i CUDA) OnlyFullyQualifiedCDIDevices() bool
- func (i CUDA) VisibleDevices() []string
- type CapabilitiesGetter
- type DriverCapabilities
- func (c DriverCapabilities) Any(capabilities ...DriverCapability) bool
- func (c DriverCapabilities) Has(capability DriverCapability) bool
- func (c DriverCapabilities) Intersection(s2 DriverCapabilities) DriverCapabilities
- func (c DriverCapabilities) IsAll() bool
- func (c DriverCapabilities) IsSuperset(s2 DriverCapabilities) bool
- func (c DriverCapabilities) List() []string
- func (c DriverCapabilities) String() string
- type DriverCapability
- type OCISpec
- type OCISpecCapabilities
- type Option
- func WithAcceptDeviceListAsVolumeMounts(acceptDeviceListAsVolumeMounts bool) Option
- func WithAcceptEnvvarUnprivileged(acceptEnvvarUnprivileged bool) Option
- func WithAnnotations(annotations map[string]string) Option
- func WithAnnotationsPrefixes(annotationsPrefixes []string) Option
- func WithDisableRequire(disableRequire bool) Option
- func WithEnv(env []string) Option
- func WithEnvMap(env map[string]string) Option
- func WithLogger(logger logger.Interface) Option
- func WithMounts(mounts []specs.Mount) Option
- func WithPreferredVisibleDevicesEnvVars(preferredVisibleDeviceEnvVars ...string) Option
- func WithPrivileged(isPrivileged bool) Option
- type VisibleDevices
Constants ¶
const ( EnvVarCudaVersion = "CUDA_VERSION" EnvVarNvidiaDisableRequire = "NVIDIA_DISABLE_REQUIRE" EnvVarNvidiaDriverCapabilities = "NVIDIA_DRIVER_CAPABILITIES" EnvVarNvidiaImexChannels = "NVIDIA_IMEX_CHANNELS" EnvVarNvidiaMigConfigDevices = "NVIDIA_MIG_CONFIG_DEVICES" EnvVarNvidiaMigMonitorDevices = "NVIDIA_MIG_MONITOR_DEVICES" EnvVarNvidiaRequireCuda = NvidiaRequirePrefix + "CUDA" EnvVarNvidiaRequireJetpack = NvidiaRequirePrefix + "JETPACK" EnvVarNvidiaVisibleDevices = "NVIDIA_VISIBLE_DEVICES" NvidiaRequirePrefix = "NVIDIA_REQUIRE_" )
const (
DeviceListAsVolumeMountsRoot = "/var/run/nvidia-container-devices"
)
Variables ¶
var ( // DefaultDriverCapabilities sets the value for driver capabilities if no value is set. DefaultDriverCapabilities = NewDriverCapabilities("utility,compute") // SupportedDriverCapabilities defines the set of all supported driver capabilities. SupportedDriverCapabilities = NewDriverCapabilities("compute,compat32,graphics,utility,video,display,ngx") )
Functions ¶
func IsPrivileged ¶ added in v1.13.0
func IsPrivileged(s CapabilitiesGetter) bool
IsPrivileged returns true if the container is a privileged container.
Types ¶
type CUDA ¶
type CUDA struct {
// contains filtered or unexported fields
}
CUDA represents a CUDA image that can be used for GPU computing. This wraps a map of environment variable to values that can be used to perform lookups such as requirements.
func NewCUDAImageFromSpec ¶
NewCUDAImageFromSpec creates a CUDA image from the input OCI runtime spec. The process environment is read (if present) to construc the CUDA Image.
func (CUDA) GetDriverCapabilities ¶ added in v1.12.0
func (i CUDA) GetDriverCapabilities() DriverCapabilities
GetDriverCapabilities returns the requested driver capabilities.
func (CUDA) GetRequirements ¶
GetRequirements returns the requirements from all NVIDIA_REQUIRE_ environment variables.
func (CUDA) Getenv ¶ added in v1.15.0
Getenv returns the value of the specified environment variable. If the environment variable is not specified, an empty string is returned.
func (CUDA) HasDisableRequire ¶
HasDisableRequire checks for the value of the NVIDIA_DISABLE_REQUIRE. If set to a valid (true) boolean value this can be used to disable the requirement checks
func (CUDA) HasEnvvar ¶ added in v1.15.0
HasEnvvar checks whether the specified envvar is defined in the image.
func (CUDA) ImexChannelsFromEnvVar ¶ added in v1.17.0
ImexChannelsFromEnvVar returns the list of IMEX channels requested for the image.
func (CUDA) ImexChannelsFromMounts ¶ added in v1.17.0
ImexChannelsFromMounts returns the list of IMEX channels requested for the image.
func (CUDA) IsLegacy ¶
IsLegacy returns whether the associated CUDA image is a "legacy" image. An image is considered legacy if it has a CUDA_VERSION environment variable defined and no NVIDIA_REQUIRE_CUDA environment variable defined.
func (CUDA) IsPrivileged ¶ added in v1.18.0
func (CUDA) OnlyFullyQualifiedCDIDevices ¶ added in v1.15.0
OnlyFullyQualifiedCDIDevices returns true if all devices requested in the image are requested as CDI devices/
func (CUDA) VisibleDevices ¶ added in v1.18.0
VisibleDevices returns a list of devices requested in the container image. If volume mount requests are enabled these are returned if requested, otherwise device requests through environment variables are considered. In cases where environment variable requests required privileged containers, such devices requests are ignored.
type CapabilitiesGetter ¶ added in v1.18.0
type CapabilitiesGetter interface {
GetCapabilities() []string
}
type DriverCapabilities ¶ added in v1.12.0
type DriverCapabilities map[DriverCapability]bool
DriverCapabilities represents the NVIDIA_DRIVER_CAPABILITIES set for the specified image.
func NewDriverCapabilities ¶ added in v1.14.0
func NewDriverCapabilities(capabilities ...string) DriverCapabilities
NewDriverCapabilities creates a set of driver capabilities from the specified capabilities
func (DriverCapabilities) Any ¶ added in v1.12.0
func (c DriverCapabilities) Any(capabilities ...DriverCapability) bool
Any checks whether any of the specified capabilities are set
func (DriverCapabilities) Has ¶ added in v1.12.0
func (c DriverCapabilities) Has(capability DriverCapability) bool
Has check whether the specified capability is selected.
func (DriverCapabilities) Intersection ¶ added in v1.14.0
func (c DriverCapabilities) Intersection(s2 DriverCapabilities) DriverCapabilities
Intersection returns a new set which includes the item in BOTH d and s2. For example: d = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}
func (DriverCapabilities) IsAll ¶ added in v1.14.0
func (c DriverCapabilities) IsAll() bool
IsAll indicates whether the set of capabilities is `all`
func (DriverCapabilities) IsSuperset ¶ added in v1.14.0
func (c DriverCapabilities) IsSuperset(s2 DriverCapabilities) bool
IsSuperset returns true if and only if d is a superset of s2.
func (DriverCapabilities) List ¶ added in v1.14.0
func (c DriverCapabilities) List() []string
List returns the list of driver capabilities. The list is sorted.
func (DriverCapabilities) String ¶ added in v1.14.0
func (c DriverCapabilities) String() string
String returns the string repesentation of the driver capabilities.
type DriverCapability ¶ added in v1.12.0
type DriverCapability string
DriverCapability represents the possible values of NVIDIA_DRIVER_CAPABILITIES
const ( DriverCapabilityAll DriverCapability = "all" DriverCapabilityNone DriverCapability = "none" DriverCapabilityCompat32 DriverCapability = "compat32" DriverCapabilityCompute DriverCapability = "compute" DriverCapabilityDisplay DriverCapability = "display" DriverCapabilityGraphics DriverCapability = "graphics" DriverCapabilityNgx DriverCapability = "ngx" DriverCapabilityUtility DriverCapability = "utility" DriverCapabilityVideo DriverCapability = "video" )
Constants for the supported driver capabilities
type OCISpec ¶ added in v1.18.0
type OCISpec specs.Spec
func (OCISpec) GetCapabilities ¶ added in v1.18.0
type OCISpecCapabilities ¶ added in v1.18.0
type OCISpecCapabilities specs.LinuxCapabilities
func (OCISpecCapabilities) GetCapabilities ¶ added in v1.18.0
func (c OCISpecCapabilities) GetCapabilities() []string
type Option ¶ added in v1.14.0
type Option func(*builder) error
Option is a functional option for creating a CUDA image.
func WithAcceptDeviceListAsVolumeMounts ¶ added in v1.18.0
func WithAcceptEnvvarUnprivileged ¶ added in v1.18.0
func WithAnnotations ¶ added in v1.18.0
func WithAnnotationsPrefixes ¶ added in v1.18.0
func WithDisableRequire ¶ added in v1.14.0
WithDisableRequire sets the disable require option.
func WithEnv ¶ added in v1.14.0
WithEnv sets the environment variables to use when creating the CUDA image. Note that this also overwrites the values set with WithEnvMap.
func WithEnvMap ¶ added in v1.15.0
WithEnvMap sets the environment variable map to use when creating the CUDA image. Note that this also overwrites the values set with WithEnv.
func WithLogger ¶ added in v1.18.0
WithLogger sets the logger to use when creating the CUDA image.
func WithMounts ¶ added in v1.15.0
func WithMounts(mounts []specs.Mount) Option
WithMounts sets the mounts associated with the CUDA image.
func WithPreferredVisibleDevicesEnvVars ¶ added in v1.18.0
WithPreferredVisibleDevicesEnvVars sets the environment variables that should take precedence over the default NVIDIA_VISIBLE_DEVICES.
func WithPrivileged ¶ added in v1.18.0
WithPrivileged sets whether an image is privileged or not.
type VisibleDevices ¶ added in v1.12.0
VisibleDevices represents the devices selected in a container image through the NVIDIA_VISIBLE_DEVICES or other environment variables
func NewVisibleDevices ¶ added in v1.12.0
func NewVisibleDevices(envvars ...string) VisibleDevices
NewVisibleDevices creates a VisibleDevices based on the value of the specified envvar.