Skip to content

Commit efb18a7

Browse files
authored
Merge pull request #762 from elezar/fix-auto-cdi-runtime-mode
Fix bug when using just-in-time CDI spec generation
2 parents d78868c + 75376d3 commit efb18a7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pkg/nvcdi/lib-nvml.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (l *nvmllib) GetDeviceSpecsByID(ids ...string) ([]specs.Device, error) {
103103
return l.GetDeviceSpecsBy(identifiers...)
104104
}
105105

106-
// GetDeviceSpecsBy is not supported for the gdslib specs.
106+
// GetDeviceSpecsBy returns the device specs for devices with the specified identifiers.
107107
func (l *nvmllib) GetDeviceSpecsBy(identifiers ...device.Identifier) ([]specs.Device, error) {
108108
for _, id := range identifiers {
109109
if id == "all" {
@@ -118,10 +118,23 @@ func (l *nvmllib) GetDeviceSpecsBy(identifiers ...device.Identifier) ([]specs.De
118118
}
119119
defer func() {
120120
if r := l.nvmllib.Shutdown(); r != nvml.SUCCESS {
121-
l.logger.Warningf("failed to shutdown NVML: %w", r)
121+
l.logger.Warningf("failed to shutdown NVML: %v", r)
122122
}
123123
}()
124124

125+
if l.nvsandboxutilslib != nil {
126+
if r := l.nvsandboxutilslib.Init(l.driverRoot); r != nvsandboxutils.SUCCESS {
127+
l.logger.Warningf("Failed to init nvsandboxutils: %v; ignoring", r)
128+
l.nvsandboxutilslib = nil
129+
}
130+
defer func() {
131+
if l.nvsandboxutilslib == nil {
132+
return
133+
}
134+
_ = l.nvsandboxutilslib.Shutdown()
135+
}()
136+
}
137+
125138
nvmlDevices, err := l.getNVMLDevicesByID(identifiers...)
126139
if err != nil {
127140
return nil, fmt.Errorf("failed to get NVML device handles: %w", err)

0 commit comments

Comments
 (0)