contrib/nvidia: export helper binary path and list of Nvidia capabilities
@@ -29,7 +29,8 @@ import (
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
// Detailed explanation of options can be found:
@@ -51,7 +52,9 @@ const (
Display Capability = "display"
)
-var allCaps = []Capability{
+// AllCaps returns the complete list of supported Nvidia capabilties.
+func AllCaps() []Capability {
+ return []Capability{
Compute,
Compat32,
Graphics,
@@ -59,6 +62,7 @@ var allCaps = []Capability{
Video,
Display,
}
+}
// WithGPUs adds NVIDIA gpu support to a container
func WithGPUs(opts ...Opts) oci.SpecOpts {
@@ -76,7 +80,7 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
}
c.OCIHookPath = path
}
- nvidiaPath, err := exec.LookPath(nvidiaCLI)
+ nvidiaPath, err := exec.LookPath(NvidiaCLI)
if err != nil {
return err
}
@@ -166,7 +170,7 @@ func WithAllDevices(c *config) error {
// WithAllCapabilities adds all capabilities to the container for the gpus
func WithAllCapabilities(c *config) error {
- c.Capabilities = allCaps
+ c.Capabilities = AllCaps()
return nil
}
