mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 16:29:18 +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/cuda"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
|
"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/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/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/oci"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/requirements"
|
"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
|
// 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)
|
csvFiles = csv.BaseFilesOnly(csvFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := tegra.New(
|
cdilib, err := nvcdi.New(
|
||||||
tegra.WithLogger(logger),
|
nvcdi.WithLogger(logger),
|
||||||
tegra.WithDriverRoot(cfg.NVIDIAContainerCLIConfig.Root),
|
nvcdi.WithDriverRoot(cfg.NVIDIAContainerCLIConfig.Root),
|
||||||
tegra.WithNVIDIACTKPath(cfg.NVIDIACTKConfig.Path),
|
nvcdi.WithNVIDIACTKPath(cfg.NVIDIACTKConfig.Path),
|
||||||
tegra.WithCSVFiles(csvFiles),
|
nvcdi.WithMode(nvcdi.ModeCSV),
|
||||||
|
nvcdi.WithCSVFiles(csvFiles),
|
||||||
)
|
)
|
||||||
if err != nil {
|
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 {
|
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(
|
modifiers := Merge(
|
||||||
nvidiaContainerRuntimeHookRemover{logger},
|
nvidiaContainerRuntimeHookRemover{logger},
|
||||||
discoverModifier,
|
cdiModifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
return modifiers, nil
|
return modifiers, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user