mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Explicitly generate CDI spec for CSV mode
This change explicitly generates a CDI specification from the supplied CSV files when cdi mode is detected. This ensures consistency between the behaviour on Tegra-based systems. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
6b48cbd1dc
commit
01a7f7bb8e
@ -24,10 +24,11 @@ import (
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/cuda"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover/csv"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover/tegra"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/modifier/cdi"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/oci"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/requirements"
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi"
|
||||
)
|
||||
|
||||
// csvMode represents the modifications as performed by the csv runtime mode
|
||||
@ -65,24 +66,33 @@ func NewCSVModifier(logger logger.Interface, cfg *config.Config, image image.CUD
|
||||
csvFiles = csv.BaseFilesOnly(csvFiles)
|
||||
}
|
||||
|
||||
d, err := tegra.New(
|
||||
tegra.WithLogger(logger),
|
||||
tegra.WithDriverRoot(cfg.NVIDIAContainerCLIConfig.Root),
|
||||
tegra.WithNVIDIACTKPath(cfg.NVIDIACTKConfig.Path),
|
||||
tegra.WithCSVFiles(csvFiles),
|
||||
cdilib, err := nvcdi.New(
|
||||
nvcdi.WithLogger(logger),
|
||||
nvcdi.WithDriverRoot(cfg.NVIDIAContainerCLIConfig.Root),
|
||||
nvcdi.WithNVIDIACTKPath(cfg.NVIDIACTKConfig.Path),
|
||||
nvcdi.WithMode(nvcdi.ModeCSV),
|
||||
nvcdi.WithCSVFiles(csvFiles),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to construct discoverer: %v", err)
|
||||
return nil, fmt.Errorf("failed to construct CDI library: %v", err)
|
||||
}
|
||||
|
||||
discoverModifier, err := NewModifierFromDiscoverer(logger, d)
|
||||
spec, err := cdilib.GetSpec()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to construct modifier: %v", err)
|
||||
return nil, fmt.Errorf("failed to get CDI spec: %v", err)
|
||||
}
|
||||
|
||||
cdiModifier, err := cdi.New(
|
||||
cdi.WithLogger(logger),
|
||||
cdi.WithSpec(spec.Raw()),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to construct CDI modifier: %v", err)
|
||||
}
|
||||
|
||||
modifiers := Merge(
|
||||
nvidiaContainerRuntimeHookRemover{logger},
|
||||
discoverModifier,
|
||||
cdiModifier,
|
||||
)
|
||||
|
||||
return modifiers, nil
|
||||
|
Loading…
Reference in New Issue
Block a user