From 803f4c2a676504d4d3d92311a5c4f080218659e7 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 6 Jan 2026 14:07:52 +0100 Subject: [PATCH 1/2] fix: Don't filter device nodes when disable-multiple-csv-devices is enabled This change allows the "multiple-csv-devices" feature to be disabled using the feature flag. Without this change the /dev/nvidia1 device node is filtered out of the required set of devices which breaks certain applications. Signed-off-by: Evan Lezar --- pkg/nvcdi/lib-csv.go | 49 +++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/pkg/nvcdi/lib-csv.go b/pkg/nvcdi/lib-csv.go index 77fcd95b3..cea5ffc11 100644 --- a/pkg/nvcdi/lib-csv.go +++ b/pkg/nvcdi/lib-csv.go @@ -46,11 +46,7 @@ var _ deviceSpecGeneratorFactory = (*csvlib)(nil) // If NVML is not available or the disable-multiple-csv-devices feature flag is // enabled, a single device is assumed. func (l *csvlib) DeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, error) { - if l.featureFlags[FeatureDisableMultipleCSVDevices] { - return l.purecsvDeviceSpecGenerators(ids...) - } - hasNVML, _ := l.infolib.HasNvml() - if !hasNVML { + if l.usePureCSVDeviceSpecGenerator() { return l.purecsvDeviceSpecGenerators(ids...) } mixed, err := l.mixedDeviceSpecGenerators(ids...) @@ -61,6 +57,24 @@ func (l *csvlib) DeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, error return mixed, nil } +func (l *csvlib) usePureCSVDeviceSpecGenerator() bool { + if l.featureFlags[FeatureDisableMultipleCSVDevices] { + return true + } + hasNVML, _ := l.infolib.HasNvml() + if !hasNVML { + return true + } + asNvmlLib := (*nvmllib)(l) + err := asNvmlLib.init() + if err != nil { + return true + } + defer asNvmlLib.tryShutdown() + + return false +} + func (l *csvlib) purecsvDeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, error) { for _, id := range ids { switch id { @@ -74,6 +88,9 @@ func (l *csvlib) purecsvDeviceSpecGenerators(ids ...string) (DeviceSpecGenerator csvlib: l, index: 0, uuid: "", + // We set noFilterDeviceNodes to true to ensure that the /dev/nvidia[0-1] + // device nodes in the CSV files on the system are consumed as-is. + noFilterDeviceNodes: true, } return g, nil } @@ -86,8 +103,9 @@ func (l *csvlib) mixedDeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, // platform-specific CSV files. type csvDeviceGenerator struct { *csvlib - index int - uuid string + index int + uuid string + noFilterDeviceNodes bool } func (l *csvDeviceGenerator) GetUUID() (string, error) { @@ -132,14 +150,17 @@ func (l *csvDeviceGenerator) GetDeviceSpecs() ([]specs.Device, error) { // particular device is added to the set of device nodes to be discovered. func (l *csvDeviceGenerator) deviceNodeDiscoverer() (discover.Discover, error) { mountSpecs := tegra.Transform( - tegra.Transform( - tegra.MountSpecsFromCSVFiles(l.logger, l.csvFiles...), - // We remove non-device nodes. - tegra.OnlyDeviceNodes(), - ), - // We remove the regular (nvidia[0-9]+) device nodes. - tegra.WithoutRegularDeviceNodes(), + tegra.MountSpecsFromCSVFiles(l.logger, l.csvFiles...), + // We remove non-device nodes. + tegra.OnlyDeviceNodes(), ) + if !l.noFilterDeviceNodes { + mountSpecs = tegra.Transform( + mountSpecs, + // We remove the regular (nvidia[0-9]+) device nodes. + tegra.WithoutRegularDeviceNodes(), + ) + } return tegra.New( tegra.WithLogger(l.logger), tegra.WithDriverRoot(l.driverRoot), From 7c8d40a5a2305aae9839d52c890d6ee8481a45c1 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 6 Jan 2026 14:11:26 +0100 Subject: [PATCH 2/2] fix: Use pure CSV mode when a single device is found This change ensure that the pure CSV mode (with no device node filtering) is used when a single device is present on the system. This enables use cases such as VPI applications where the /dev/nvidia1 device node is used even though an iGPU is present. Signed-off-by: Evan Lezar --- pkg/nvcdi/lib-csv.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/nvcdi/lib-csv.go b/pkg/nvcdi/lib-csv.go index cea5ffc11..c01115462 100644 --- a/pkg/nvcdi/lib-csv.go +++ b/pkg/nvcdi/lib-csv.go @@ -72,7 +72,12 @@ func (l *csvlib) usePureCSVDeviceSpecGenerator() bool { } defer asNvmlLib.tryShutdown() - return false + numDevices, ret := l.nvmllib.DeviceGetCount() + if ret != nvml.SUCCESS { + return true + } + + return numDevices <= 1 } func (l *csvlib) purecsvDeviceSpecGenerators(ids ...string) (DeviceSpecGenerator, error) {