mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Use require-nvidia-kernel-modules feature for toolkit installation
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
7263d26817
commit
ac61306900
@ -36,7 +36,6 @@ type executable struct {
|
|||||||
source string
|
source string
|
||||||
target executableTarget
|
target executableTarget
|
||||||
env map[string]string
|
env map[string]string
|
||||||
preLines []string
|
|
||||||
argLines []string
|
argLines []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,11 +95,6 @@ func (e executable) writeWrapperTo(wrapper io.Writer, destFolder string, dotfile
|
|||||||
// Add the shebang
|
// Add the shebang
|
||||||
fmt.Fprintln(wrapper, "#! /bin/sh")
|
fmt.Fprintln(wrapper, "#! /bin/sh")
|
||||||
|
|
||||||
// Add the preceding lines if any
|
|
||||||
for _, line := range e.preLines {
|
|
||||||
fmt.Fprintf(wrapper, "%s\n", r.apply(line))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the path to include the destination folder
|
// Update the path to include the destination folder
|
||||||
var env map[string]string
|
var env map[string]string
|
||||||
if e.env == nil {
|
if e.env == nil {
|
||||||
|
@ -59,23 +59,6 @@ func TestWrapper(t *testing.T) {
|
|||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
e: executable{
|
|
||||||
preLines: []string{
|
|
||||||
"preline1",
|
|
||||||
"preline2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
expectedLines: []string{
|
|
||||||
shebang,
|
|
||||||
"preline1",
|
|
||||||
"preline2",
|
|
||||||
"PATH=/dest/folder:$PATH \\",
|
|
||||||
"source.real \\",
|
|
||||||
"\t\"$@\"",
|
|
||||||
"",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
e: executable{
|
e: executable{
|
||||||
argLines: []string{
|
argLines: []string{
|
||||||
|
@ -57,16 +57,6 @@ func newNvidiaContainerRuntimeInstaller(source string) *executable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newRuntimeInstaller(source string, target executableTarget, env map[string]string) *executable {
|
func newRuntimeInstaller(source string, target executableTarget, env map[string]string) *executable {
|
||||||
preLines := []string{
|
|
||||||
"",
|
|
||||||
"cat /proc/modules | grep -e \"^nvidia \" >/dev/null 2>&1",
|
|
||||||
"if [ \"${?}\" != \"0\" ]; then",
|
|
||||||
" echo \"nvidia driver modules are not yet loaded, invoking runc directly\"",
|
|
||||||
" exec runc \"$@\"",
|
|
||||||
"fi",
|
|
||||||
"",
|
|
||||||
}
|
|
||||||
|
|
||||||
runtimeEnv := make(map[string]string)
|
runtimeEnv := make(map[string]string)
|
||||||
runtimeEnv["XDG_CONFIG_HOME"] = filepath.Join(destDirPattern, ".config")
|
runtimeEnv["XDG_CONFIG_HOME"] = filepath.Join(destDirPattern, ".config")
|
||||||
for k, v := range env {
|
for k, v := range env {
|
||||||
@ -74,10 +64,9 @@ func newRuntimeInstaller(source string, target executableTarget, env map[string]
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := executable{
|
r := executable{
|
||||||
source: source,
|
source: source,
|
||||||
target: target,
|
target: target,
|
||||||
env: runtimeEnv,
|
env: runtimeEnv,
|
||||||
preLines: preLines,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &r
|
return &r
|
||||||
|
@ -38,13 +38,6 @@ func TestNvidiaContainerRuntimeInstallerWrapper(t *testing.T) {
|
|||||||
|
|
||||||
expectedLines := []string{
|
expectedLines := []string{
|
||||||
shebang,
|
shebang,
|
||||||
"",
|
|
||||||
"cat /proc/modules | grep -e \"^nvidia \" >/dev/null 2>&1",
|
|
||||||
"if [ \"${?}\" != \"0\" ]; then",
|
|
||||||
" echo \"nvidia driver modules are not yet loaded, invoking runc directly\"",
|
|
||||||
" exec runc \"$@\"",
|
|
||||||
"fi",
|
|
||||||
"",
|
|
||||||
"PATH=/dest/folder:$PATH \\",
|
"PATH=/dest/folder:$PATH \\",
|
||||||
"XDG_CONFIG_HOME=/dest/folder/.config \\",
|
"XDG_CONFIG_HOME=/dest/folder/.config \\",
|
||||||
"source.real \\",
|
"source.real \\",
|
||||||
|
@ -465,6 +465,8 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai
|
|||||||
configValues["nvidia-container-runtime.runtimes"] = toolkitRuntimeList
|
configValues["nvidia-container-runtime.runtimes"] = toolkitRuntimeList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We require the NVIDIA kernel modules to be loaded.
|
||||||
|
configValues["features.require-nvidia-kernel-modules"] = true
|
||||||
for _, optInFeature := range opts.optInFeatures.Value() {
|
for _, optInFeature := range opts.optInFeatures.Value() {
|
||||||
configValues["features."+optInFeature] = true
|
configValues["features."+optInFeature] = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user