From b3de846f66fd37559b7eba47c982bb7aba1da398 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Fri, 20 Dec 2019 16:02:51 +0000 Subject: [PATCH] Cleanup names of constants to better match ENVVARs Signed-off-by: Kevin Klues --- nvidia-container-toolkit/container_config.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nvidia-container-toolkit/container_config.go b/nvidia-container-toolkit/container_config.go index ef46c72a..e6ce7684 100644 --- a/nvidia-container-toolkit/container_config.go +++ b/nvidia-container-toolkit/container_config.go @@ -13,14 +13,17 @@ import ( var envSwarmGPU *string const ( + envCUDAVersion = "CUDA_VERSION" envNVRequirePrefix = "NVIDIA_REQUIRE_" - envLegacyCUDAVersion = "CUDA_VERSION" envNVRequireCUDA = envNVRequirePrefix + "CUDA" - envNVGPU = "NVIDIA_VISIBLE_DEVICES" - envNVDriverCapabilities = "NVIDIA_DRIVER_CAPABILITIES" - defaultCapability = "utility" - allCapabilities = "compute,compat32,graphics,utility,video,display" envNVDisableRequire = "NVIDIA_DISABLE_REQUIRE" + envNVVisibleDevices = "NVIDIA_VISIBLE_DEVICES" + envNVDriverCapabilities = "NVIDIA_DRIVER_CAPABILITIES" +) + +const ( + allCapabilities = "compute,compat32,graphics,utility,video,display" + defaultCapability = "utility" ) type nvidiaConfig struct { @@ -111,7 +114,7 @@ func loadSpec(path string) (spec *Spec) { } func getDevices(env map[string]string) *string { - gpuVars := []string{envNVGPU} + gpuVars := []string{envNVVisibleDevices} if envSwarmGPU != nil { // The Swarm resource has higher precedence. gpuVars = append([]string{*envSwarmGPU}, gpuVars...) @@ -177,7 +180,7 @@ func getNvidiaConfigLegacy(env map[string]string) *nvidiaConfig { requirements := getRequirements(env) - vmaj, vmin, _ := parseCudaVersion(env[envLegacyCUDAVersion]) + vmaj, vmin, _ := parseCudaVersion(env[envCUDAVersion]) cudaRequire := fmt.Sprintf("cuda>=%d.%d", vmaj, vmin) requirements = append(requirements, cudaRequire) @@ -193,7 +196,7 @@ func getNvidiaConfigLegacy(env map[string]string) *nvidiaConfig { } func getNvidiaConfig(env map[string]string) *nvidiaConfig { - legacyCudaVersion := env[envLegacyCUDAVersion] + legacyCudaVersion := env[envCUDAVersion] cudaRequire := env[envNVRequireCUDA] if len(legacyCudaVersion) > 0 && len(cudaRequire) == 0 { // Legacy CUDA image detected.