10000 contrib/nvidia: export helper binary path and list of Nvidia capabili… · containerd/containerd@7ca2c3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ca2c3d

Browse files
author
Tibor Vass
committed
contrib/nvidia: export helper binary path and list of Nvidia capabilities
Signed-off-by: Tibor Vass <tibor@docker.com>
1 parent 09da2d8 commit 7ca2c3d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

contrib/nvidia/nvidia.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import (
2929
specs "github.com/opencontainers/runtime-spec/specs-go"
3030
)
3131

32-
const nvidiaCLI = "nvidia-container-cli"
32+
// NvidiaCLI is the path to the Nvidia helper binary
33+
const NvidiaCLI = "nvidia-container-cli"
3334

3435
// Capability specifies capabilities for the gpu inside the container
3536
// Detailed explanation of options can be found:
@@ -51,13 +52,16 @@ const (
5152
Display Capability = "display"
5253
)
5354

54-
var allCaps = []Capability{
55-
Compute,
56-
Compat32,
57-
Graphics,
58-
Utility,
59-
Video,
60-
Display,
55+
// AllCaps returns the complete list of supported Nvidia capabilties.
56+
func AllCaps() []Capability {
57+
return []Capability{
58+
Compute,
59+
Compat32,
60+
Graphics,
61+
Utility,
62+
Video,
63+
Display,
64+
}
6165
}
6266

6367
// WithGPUs adds NVIDIA gpu support to a container
@@ -76,7 +80,7 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
7680
}
7781
c.OCIHookPath = path
7882
}
79-
nvidiaPath, err := exec.LookPath(nvidiaCLI)
83+
nvidiaPath, err := exec.LookPath(NvidiaCLI)
8084
if err != nil {
8185
return err
8286
}
@@ -166,7 +170,7 @@ func WithAllDevices(c *config) error {
166170

167171
// WithAllCapabilities adds all capabilities to the container for the gpus
168172
func WithAllCapabilities(c *config) error {
169-
c.Capabilities = allCaps
173+
c.Capabilities = AllCaps()
170174
return nil
171175
}
172176

0 commit comments

Comments
 (0)
0