Skip to content

Commit 940aaac

Browse files
committed
invoke the actual default low-level runtime in the nvidia-ctk wrapper script
Signed-off-by: Tariq Ibrahim <[email protected]>
1 parent f0f9f37 commit 940aaac

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

cmd/nvidia-ctk-installer/toolkit/installer/executables.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ func (t *ToolkitInstaller) collectExecutables(destDir string) ([]Installer, erro
9191
dotRealFilename := wrappedExecutableFilename + ".real"
9292

9393
w := &wrapper{
94-
Source: executablePath,
95-
WrappedExecutable: dotRealFilename,
96-
CheckModules: executable.requiresKernelModule,
94+
Source: executablePath,
95+
WrappedExecutable: dotRealFilename,
96+
CheckModules: executable.requiresKernelModule,
97+
DefaultRuntimeExecutablePath: t.defaultRuntimeExecutablePath,
9798
Envvars: map[string]string{
9899
"PATH": strings.Join([]string{destDir, "$PATH"}, ":"),
99100
},
@@ -119,10 +120,11 @@ func (t *ToolkitInstaller) collectExecutables(destDir string) ([]Installer, erro
119120
}
120121

121122
type wrapper struct {
122-
Source string
123-
Envvars map[string]string
124-
WrappedExecutable string
125-
CheckModules bool
123+
Source string
124+
Envvars map[string]string
125+
WrappedExecutable string
126+
CheckModules bool
127+
DefaultRuntimeExecutablePath string
126128
}
127129

128130
type render struct {
@@ -155,8 +157,8 @@ func (w *render) render() (io.Reader, error) {
155157
{{- if (.CheckModules) }}
156158
cat /proc/modules | grep -e "^nvidia " >/dev/null 2>&1
157159
if [ "${?}" != "0" ]; then
158-
echo "nvidia driver modules are not yet loaded, invoking runc directly"
159-
exec runc "$@"
160+
echo "nvidia driver modules are not yet loaded, invoking {{ .DefaultRuntimeExecutablePath }} directly"
161+
exec {{ .DefaultRuntimeExecutablePath }} "$@"
160162
fi
161163
{{- end }}
162164
{{- range $key, $value := .Envvars }}

cmd/nvidia-ctk-installer/toolkit/installer/installer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type ToolkitInstaller struct {
4141
artifactRoot *artifactRoot
4242

4343
ensureTargetDirectory Installer
44+
45+
defaultRuntimeExecutablePath string
4446
}
4547

4648
var _ Installer = (*ToolkitInstaller)(nil)

cmd/nvidia-ctk-installer/toolkit/installer/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ func WithSourceRoot(sourceRoot string) Option {
4545
ti.sourceRoot = sourceRoot
4646
}
4747
}
48+
49+
func WithDefaultRuntimeExecutablePath(path string) Option {
50+
return func(ti *ToolkitInstaller) {
51+
ti.defaultRuntimeExecutablePath = path
52+
}
53+
}

cmd/nvidia-ctk-installer/toolkit/toolkit.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,25 @@ func (t *Installer) Install(cli *cli.Command, opts *Options) error {
295295
t.logger.Errorf("Ignoring error: %v", fmt.Errorf("error removing toolkit directory: %v", err))
296296
}
297297

298+
defaultRuntimeExecutable := "runc"
299+
if len(opts.ContainerRuntimeRuntimes) > 0 {
300+
defaultRuntimeExecutable = opts.ContainerRuntimeRuntimes[0]
301+
}
302+
298303
// Create a toolkit installer to actually install the toolkit components.
299304
toolkit, err := installer.New(
300305
installer.WithLogger(t.logger),
301306
installer.WithSourceRoot(t.sourceRoot),
302307
installer.WithIgnoreErrors(opts.ignoreErrors),
308+
installer.WithDefaultRuntimeExecutablePath(defaultRuntimeExecutable),
303309
)
304310
if err != nil {
305311
if !opts.ignoreErrors {
306312
return fmt.Errorf("could not create toolkit installer: %w", err)
307313
}
308314
t.logger.Errorf("Ignoring error: %v", fmt.Errorf("could not create toolkit installer: %w", err))
309315
}
316+
310317
if err := toolkit.Install(t.toolkitRoot); err != nil {
311318
if !opts.ignoreErrors {
312319
return fmt.Errorf("could not install toolkit components: %w", err)

0 commit comments

Comments
 (0)