contrib/nvidia: export helper binary path and list of Nvidia capabilities
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
09da2d867a
commit
7ca2c3d68d
@ -29,7 +29,8 @@ import (
|
|||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
const nvidiaCLI = "nvidia-container-cli"
|
// NvidiaCLI is the path to the Nvidia helper binary
|
||||||
|
const NvidiaCLI = "nvidia-container-cli"
|
||||||
|
|
||||||
// Capability specifies capabilities for the gpu inside the container
|
// Capability specifies capabilities for the gpu inside the container
|
||||||
// Detailed explanation of options can be found:
|
// Detailed explanation of options can be found:
|
||||||
@ -51,13 +52,16 @@ const (
|
|||||||
Display Capability = "display"
|
Display Capability = "display"
|
||||||
)
|
)
|
||||||
|
|
||||||
var allCaps = []Capability{
|
// AllCaps returns the complete list of supported Nvidia capabilties.
|
||||||
Compute,
|
func AllCaps() []Capability {
|
||||||
Compat32,
|
return []Capability{
|
||||||
Graphics,
|
Compute,
|
||||||
Utility,
|
Compat32,
|
||||||
Video,
|
Graphics,
|
||||||
Display,
|
Utility,
|
||||||
|
Video,
|
||||||
|
Display,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithGPUs adds NVIDIA gpu support to a container
|
// WithGPUs adds NVIDIA gpu support to a container
|
||||||
@ -76,7 +80,7 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
|
|||||||
}
|
}
|
||||||
c.OCIHookPath = path
|
c.OCIHookPath = path
|
||||||
}
|
}
|
||||||
nvidiaPath, err := exec.LookPath(nvidiaCLI)
|
nvidiaPath, err := exec.LookPath(NvidiaCLI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -166,7 +170,7 @@ func WithAllDevices(c *config) error {
|
|||||||
|
|
||||||
// WithAllCapabilities adds all capabilities to the container for the gpus
|
// WithAllCapabilities adds all capabilities to the container for the gpus
|
||||||
func WithAllCapabilities(c *config) error {
|
func WithAllCapabilities(c *config) error {
|
||||||
c.Capabilities = allCaps
|
c.Capabilities = AllCaps()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user