mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 13:35:00 +00:00
Merge branch 'remove-config-import-from-discover' into 'main'
Remove NewGraphicsDiscoverer API simplification See merge request nvidia/container-toolkit/container-toolkit!498
This commit is contained in:
commit
039d7fd324
@ -22,7 +22,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"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"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/info/drm"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/info/drm"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc"
|
||||||
@ -31,18 +30,12 @@ import (
|
|||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/cuda"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/cuda"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewGraphicsDiscoverer returns the discoverer for graphics tools such as Vulkan.
|
// NewDRMNodesDiscoverer returns a discoverrer for the DRM device nodes associated with the specified visible devices.
|
||||||
func NewGraphicsDiscoverer(logger logger.Interface, cfg *config.Config, devices image.VisibleDevices) (Discover, error) {
|
//
|
||||||
driverRoot := cfg.NVIDIAContainerCLIConfig.Root
|
// TODO: The logic for creating DRM devices should be consolidated between this
|
||||||
// In standard usage, the devRoot is the same as the driverRoot.
|
// and the logic for generating CDI specs for a single device. This is only used
|
||||||
devRoot := driverRoot
|
// when applying OCI spec modifications to an incoming spec in "legacy" mode.
|
||||||
nvidiaCTKPath := cfg.NVIDIACTKConfig.Path
|
func NewDRMNodesDiscoverer(logger logger.Interface, devices image.VisibleDevices, devRoot string, nvidiaCTKPath string) (Discover, error) {
|
||||||
|
|
||||||
mounts, err := NewGraphicsMountsDiscoverer(logger, driverRoot, nvidiaCTKPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to create mounts discoverer: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, devRoot)
|
drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, devRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err)
|
return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err)
|
||||||
@ -50,11 +43,7 @@ func NewGraphicsDiscoverer(logger logger.Interface, cfg *config.Config, devices
|
|||||||
|
|
||||||
drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, devRoot, nvidiaCTKPath)
|
drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, devRoot, nvidiaCTKPath)
|
||||||
|
|
||||||
discover := Merge(
|
discover := Merge(drmDeviceNodes, drmByPathSymlinks)
|
||||||
Merge(drmDeviceNodes, drmByPathSymlinks),
|
|
||||||
mounts,
|
|
||||||
)
|
|
||||||
|
|
||||||
return discover, nil
|
return discover, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,15 +34,34 @@ func NewGraphicsModifier(logger logger.Interface, cfg *config.Config, image imag
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := discover.NewGraphicsDiscoverer(
|
driverRoot := cfg.NVIDIAContainerCLIConfig.Root
|
||||||
|
nvidiaCTKPath := cfg.NVIDIACTKConfig.Path
|
||||||
|
|
||||||
|
mounts, err := discover.NewGraphicsMountsDiscoverer(
|
||||||
|
logger,
|
||||||
|
driverRoot,
|
||||||
|
nvidiaCTKPath,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create mounts discoverer: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// In standard usage, the devRoot is the same as the driverRoot.
|
||||||
|
devRoot := driverRoot
|
||||||
|
drmNodes, err := discover.NewDRMNodesDiscoverer(
|
||||||
logger,
|
logger,
|
||||||
cfg,
|
|
||||||
image.DevicesFromEnvvars(visibleDevicesEnvvar),
|
image.DevicesFromEnvvars(visibleDevicesEnvvar),
|
||||||
|
devRoot,
|
||||||
|
nvidiaCTKPath,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to construct discoverer: %v", err)
|
return nil, fmt.Errorf("failed to construct discoverer: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d := discover.Merge(
|
||||||
|
drmNodes,
|
||||||
|
mounts,
|
||||||
|
)
|
||||||
return NewModifierFromDiscoverer(logger, d)
|
return NewModifierFromDiscoverer(logger, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user