diff --git a/config/config.toml.amzn b/config/config.toml.amzn index 33d8e827..4de3d1c9 100644 --- a/config/config.toml.amzn +++ b/config/config.toml.amzn @@ -1,5 +1,7 @@ disable-require = false #swarm-resource = "DOCKER_RESOURCE_GPU" +#accept-nvidia-visible-devices-envvar-when-unprivileged = true +#look-for-nvidia-visible-devices-as-volume-mounts-under = "/var/run/nvidia-container-devices" [nvidia-container-cli] #root = "/run/nvidia/driver" diff --git a/config/config.toml.centos b/config/config.toml.centos index 33d8e827..4de3d1c9 100644 --- a/config/config.toml.centos +++ b/config/config.toml.centos @@ -1,5 +1,7 @@ disable-require = false #swarm-resource = "DOCKER_RESOURCE_GPU" +#accept-nvidia-visible-devices-envvar-when-unprivileged = true +#look-for-nvidia-visible-devices-as-volume-mounts-under = "/var/run/nvidia-container-devices" [nvidia-container-cli] #root = "/run/nvidia/driver" diff --git a/config/config.toml.debian b/config/config.toml.debian index 33d8e827..4de3d1c9 100644 --- a/config/config.toml.debian +++ b/config/config.toml.debian @@ -1,5 +1,7 @@ disable-require = false #swarm-resource = "DOCKER_RESOURCE_GPU" +#accept-nvidia-visible-devices-envvar-when-unprivileged = true +#look-for-nvidia-visible-devices-as-volume-mounts-under = "/var/run/nvidia-container-devices" [nvidia-container-cli] #root = "/run/nvidia/driver" diff --git a/config/config.toml.opensuse-leap b/config/config.toml.opensuse-leap index cee982ad..fe28e163 100644 --- a/config/config.toml.opensuse-leap +++ b/config/config.toml.opensuse-leap @@ -1,5 +1,7 @@ disable-require = false #swarm-resource = "DOCKER_RESOURCE_GPU" +#accept-nvidia-visible-devices-envvar-when-unprivileged = true +#look-for-nvidia-visible-devices-as-volume-mounts-under = "/var/run/nvidia-container-devices" [nvidia-container-cli] #root = "/run/nvidia/driver" diff --git a/config/config.toml.ubuntu b/config/config.toml.ubuntu index 0acaae6a..061c0759 100644 --- a/config/config.toml.ubuntu +++ b/config/config.toml.ubuntu @@ -1,5 +1,7 @@ disable-require = false #swarm-resource = "DOCKER_RESOURCE_GPU" +#accept-nvidia-visible-devices-envvar-when-unprivileged = true +#look-for-nvidia-visible-devices-as-volume-mounts-under = "/var/run/nvidia-container-devices" [nvidia-container-cli] #root = "/run/nvidia/driver" diff --git a/pkg/hook_config.go b/pkg/hook_config.go index 23cafcbd..09b78e14 100644 --- a/pkg/hook_config.go +++ b/pkg/hook_config.go @@ -13,6 +13,10 @@ const ( driverPath = "/run/nvidia/driver" ) +const ( + defaultDeviceListVolumeMount = "/var/run/nvidia-container-devices" +) + var defaultPaths = [...]string{ path.Join(driverPath, configPath), configPath, @@ -34,16 +38,20 @@ type CLIConfig struct { // HookConfig : options for the nvidia-container-toolkit. type HookConfig struct { - DisableRequire bool `toml:"disable-require"` - SwarmResource *string `toml:"swarm-resource"` + DisableRequire bool `toml:"disable-require"` + SwarmResource *string `toml:"swarm-resource"` + AcceptEnvvarUnprivileged bool `toml:"accept-nvidia-visible-devices-envvar-when-unprivileged"` + DeviceListVolumeMount *string `toml:"look-for-nvidia-visible-devices-as-volume-mounts-under"` NvidiaContainerCLI CLIConfig `toml:"nvidia-container-cli"` } func getDefaultHookConfig() (config HookConfig) { return HookConfig{ - DisableRequire: false, - SwarmResource: nil, + DisableRequire: false, + SwarmResource: nil, + AcceptEnvvarUnprivileged: true, + DeviceListVolumeMount: &[]string{defaultDeviceListVolumeMount}[0], NvidiaContainerCLI: CLIConfig{ Root: nil, Path: nil,