diff --git a/cmd/nvidia-container-toolkit/hook_config.go b/cmd/nvidia-container-toolkit/hook_config.go index b4cb0133..6a6d18b3 100644 --- a/cmd/nvidia-container-toolkit/hook_config.go +++ b/cmd/nvidia-container-toolkit/hook_config.go @@ -7,6 +7,7 @@ import ( "reflect" "github.com/BurntSushi/toml" + "github.com/NVIDIA/nvidia-container-toolkit/internal/config" ) const ( @@ -41,10 +42,11 @@ type HookConfig struct { AcceptDeviceListAsVolumeMounts bool `toml:"accept-nvidia-visible-devices-as-volume-mounts"` SupportedDriverCapabilities DriverCapabilities `toml:"supported-driver-capabilities"` - NvidiaContainerCLI CLIConfig `toml:"nvidia-container-cli"` + NvidiaContainerCLI CLIConfig `toml:"nvidia-container-cli"` + NVIDIAContainerRuntime config.RuntimeConfig `toml:"nvidia-container-runtime"` } -func getDefaultHookConfig() (config HookConfig) { +func getDefaultHookConfig() HookConfig { return HookConfig{ DisableRequire: false, SwarmResource: nil, @@ -63,6 +65,7 @@ func getDefaultHookConfig() (config HookConfig) { User: nil, Ldconfig: nil, }, + NVIDIAContainerRuntime: *config.GetDefaultRuntimeConfig(), } } diff --git a/cmd/nvidia-container-toolkit/main.go b/cmd/nvidia-container-toolkit/main.go index 13f8197c..81c86572 100644 --- a/cmd/nvidia-container-toolkit/main.go +++ b/cmd/nvidia-container-toolkit/main.go @@ -17,6 +17,7 @@ import ( var ( debugflag = flag.Bool("debug", false, "enable debug output") + forceflag = flag.Bool("force", false, "force execution of prestart hook in experimental mode") configflag = flag.String("config", "", "configuration file") defaultPATH = []string{"/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin"} @@ -85,6 +86,10 @@ func doPrestart() { hook := getHookConfig() cli := hook.NvidiaContainerCLI + if hook.NVIDIAContainerRuntime.Experimental && !*forceflag { + log.Panicln("invoking the NVIDIA Container Runtime Hook directly (e.g. specifying the docker --gpus flag) is not supported. Please use the NVIDIA Container Runtime instead.") + } + container := getContainerConfig(hook) nvidia := container.Nvidia if nvidia == nil {