mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Allow accept-visible-devices config options to be set
This change allows the * accept-nvidia-visible-devices-envvar-when-unprivileged * accept-nvidia-visible-devices-as-volume-mounts options to be set in the toolkit-container. These are controlled by command line flags or the following environment variables: * ACCEPT_NVIDIA_VISIBLE_DEVICES_ENVVAR_WHEN_UNPRIVILEGED * ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTS Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
9c060f06ba
commit
90518e0ce5
@ -45,6 +45,9 @@ type options struct {
|
||||
ContainerRuntimeLogLevel string
|
||||
ContainerCLIDebug string
|
||||
toolkitRoot string
|
||||
|
||||
acceptNVIDIAVisibleDevicesWhenUnprivileged bool
|
||||
acceptNVIDIAVisibleDevicesAsVolumeMounts bool
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -111,6 +114,18 @@ func main() {
|
||||
Destination: &opts.ContainerCLIDebug,
|
||||
EnvVars: []string{"NVIDIA_CONTAINER_CLI_DEBUG"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "accept-nvidia-visible-devices-envvar-when-unprivileged",
|
||||
Usage: "Set the accept-nvidia-visible-devices-envvar-when-unprivileged config option",
|
||||
Destination: &opts.acceptNVIDIAVisibleDevicesWhenUnprivileged,
|
||||
EnvVars: []string{"ACCEPT_NVIDIA_VISIBLE_DEVICES_ENVVAR_WHEN_UNPRIVILEGED"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "accept-nvidia-visible-devices-as-volume-mounts",
|
||||
Usage: "Set the accept-nvidia-visible-devices-as-volume-mounts config option",
|
||||
Destination: &opts.acceptNVIDIAVisibleDevicesWhenUnprivileged,
|
||||
EnvVars: []string{"ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTS"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "toolkit-root",
|
||||
Usage: "The directory where the NVIDIA Container toolkit is to be installed",
|
||||
@ -260,6 +275,10 @@ func installToolkitConfig(toolkitConfigPath string, nvidiaContainerCliExecutable
|
||||
}
|
||||
defer targetConfig.Close()
|
||||
|
||||
// Set the options in the root toml table
|
||||
config.Set("accept-nvidia-visible-devices-envvar-when-unprivileged", opts.acceptNVIDIAVisibleDevicesWhenUnprivileged)
|
||||
config.Set("accept-nvidia-visible-devices-as-volume-mounts", opts.acceptNVIDIAVisibleDevicesAsVolumeMounts)
|
||||
|
||||
nvidiaContainerCliKey := func(p string) []string {
|
||||
return []string{"nvidia-container-cli", p}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user