Also trigger graphics modifier for display capability

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2022-09-29 14:45:22 +02:00
parent cd7ee5a435
commit 73e65edaa9
2 changed files with 10 additions and 11 deletions

View File

@ -18,7 +18,6 @@ package modifier
import ( import (
"fmt" "fmt"
"strings"
"github.com/NVIDIA/nvidia-container-toolkit/internal/config" "github.com/NVIDIA/nvidia-container-toolkit/internal/config"
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/image" "github.com/NVIDIA/nvidia-container-toolkit/internal/config/image"
@ -59,16 +58,8 @@ func requiresGraphicsModifier(cudaImage image.CUDA) (bool, string) {
return false, "no devices requested" return false, "no devices requested"
} }
var hasGraphics bool if !cudaImage.GetDriverCapabilities().Any(image.DriverCapabilityGraphics, image.DriverCapabilityDisplay) {
for _, c := range strings.Split(cudaImage["NVIDIA_DRIVER_CAPABILITIES"], ",") { return false, "no required capabilities requested"
if c == "graphics" || c == "all" {
hasGraphics = true
break
}
}
if !hasGraphics {
return false, fmt.Sprintf("Capability %q not selected", "graphics")
} }
return true, "" return true, ""

View File

@ -69,6 +69,14 @@ func TestGraphicsModifier(t *testing.T) {
}, },
expectedRequired: true, expectedRequired: true,
}, },
{
description: "devices with display capability creates modifier",
cudaImage: image.CUDA{
"NVIDIA_VISIBLE_DEVICES": "all",
"NVIDIA_DRIVER_CAPABILITIES": "display",
},
expectedRequired: true,
},
{ {
description: "devices with display,graphics capability creates modifier", description: "devices with display,graphics capability creates modifier",
cudaImage: image.CUDA{ cudaImage: image.CUDA{