Skip to content

Commit ac61306

Browse files
committed
Use require-nvidia-kernel-modules feature for toolkit installation
Signed-off-by: Evan Lezar <[email protected]>
1 parent 7263d26 commit ac61306

File tree

5 files changed

+5
-44
lines changed

5 files changed

+5
-44
lines changed

tools/container/toolkit/executable.go

-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type executable struct {
3636
source string
3737
target executableTarget
3838
env map[string]string
39-
preLines []string
4039
argLines []string
4140
}
4241

@@ -96,11 +95,6 @@ func (e executable) writeWrapperTo(wrapper io.Writer, destFolder string, dotfile
9695
// Add the shebang
9796
fmt.Fprintln(wrapper, "#! /bin/sh")
9897

99-
// Add the preceding lines if any
100-
for _, line := range e.preLines {
101-
fmt.Fprintf(wrapper, "%s\n", r.apply(line))
102-
}
103-
10498
// Update the path to include the destination folder
10599
var env map[string]string
106100
if e.env == nil {

tools/container/toolkit/executable_test.go

-17
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,6 @@ func TestWrapper(t *testing.T) {
5959
"",
6060
},
6161
},
62-
{
63-
e: executable{
64-
preLines: []string{
65-
"preline1",
66-
"preline2",
67-
},
68-
},
69-
expectedLines: []string{
70-
shebang,
71-
"preline1",
72-
"preline2",
73-
"PATH=/dest/folder:$PATH \\",
74-
"source.real \\",
75-
"\t\"$@\"",
76-
"",
77-
},
78-
},
7962
{
8063
e: executable{
8164
argLines: []string{

tools/container/toolkit/runtime.go

+3-14
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,16 @@ func newNvidiaContainerRuntimeInstaller(source string) *executable {
5757
}
5858

5959
func newRuntimeInstaller(source string, target executableTarget, env map[string]string) *executable {
60-
preLines := []string{
61-
"",
62-
"cat /proc/modules | grep -e \"^nvidia \" >/dev/null 2>&1",
63-
"if [ \"${?}\" != \"0\" ]; then",
64-
" echo \"nvidia driver modules are not yet loaded, invoking runc directly\"",
65-
" exec runc \"$@\"",
66-
"fi",
67-
"",
68-
}
69-
7060
runtimeEnv := make(map[string]string)
7161
runtimeEnv["XDG_CONFIG_HOME"] = filepath.Join(destDirPattern, ".config")
7262
for k, v := range env {
7363
runtimeEnv[k] = v
7464
}
7565

7666
r := executable{
77-
source: source,
78-
target: target,
79-
env: runtimeEnv,
80-
preLines: preLines,
67+
source: source,
68+
target: target,
69+
env: runtimeEnv,
8170
}
8271

8372
return &r

tools/container/toolkit/runtime_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ func TestNvidiaContainerRuntimeInstallerWrapper(t *testing.T) {
3838

3939
expectedLines := []string{
4040
shebang,
41-
"",
42-
"cat /proc/modules | grep -e \"^nvidia \" >/dev/null 2>&1",
43-
"if [ \"${?}\" != \"0\" ]; then",
44-
" echo \"nvidia driver modules are not yet loaded, invoking runc directly\"",
45-
" exec runc \"$@\"",
46-
"fi",
47-
"",
4841
"PATH=/dest/folder:$PATH \\",
4942
"XDG_CONFIG_HOME=/dest/folder/.config \\",
5043
"source.real \\",

tools/container/toolkit/toolkit.go

+2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai
465465
configValues["nvidia-container-runtime.runtimes"] = toolkitRuntimeList
466466
}
467467

468+
// We require the NVIDIA kernel modules to be loaded.
469+
configValues["features.require-nvidia-kernel-modules"] = true
468470
for _, optInFeature := range opts.optInFeatures.Value() {
469471
configValues["features."+optInFeature] = true
470472
}

0 commit comments

Comments
 (0)