Skip to content

Commit 4604e3b

Browse files
authored
Merge pull request #725 from elezar/fix-nvsandboxutils
Ensure that nvsandboxutils is available for version
2 parents 19482da + 7cd2aef commit 4604e3b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/nvcdi/lib.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ func (l *nvcdilib) getCudaVersionNvml() (string, error) {
263263
}
264264

265265
func (l *nvcdilib) getCudaVersionNvsandboxutils() (string, error) {
266+
if l.nvsandboxutilslib == nil {
267+
return "", fmt.Errorf("libnvsandboxutils is not available")
268+
}
269+
266270
// Sandboxutils initialization should happen before this function is called
267271
version, ret := l.nvsandboxutilslib.GetDriverVersion()
268272
if ret != nvsandboxutils.SUCCESS {

pkg/nvcdi/management.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/NVIDIA/nvidia-container-toolkit/internal/discover"
2929
"github.com/NVIDIA/nvidia-container-toolkit/internal/edits"
3030
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/cuda"
31+
"github.com/NVIDIA/nvidia-container-toolkit/internal/nvsandboxutils"
3132
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec"
3233
)
3334

@@ -61,6 +62,19 @@ func (m *managementlib) GetAllDeviceSpecs() ([]specs.Device, error) {
6162

6263
// GetCommonEdits returns the common edits for use in managementlib containers.
6364
func (m *managementlib) GetCommonEdits() (*cdi.ContainerEdits, error) {
65+
if m.nvsandboxutilslib != nil {
66+
if r := m.nvsandboxutilslib.Init(m.driverRoot); r != nvsandboxutils.SUCCESS {
67+
m.logger.Warningf("Failed to init nvsandboxutils: %v; ignoring", r)
68+
m.nvsandboxutilslib = nil
69+
}
70+
defer func() {
71+
if m.nvsandboxutilslib == nil {
72+
return
73+
}
74+
_ = m.nvsandboxutilslib.Shutdown()
75+
}()
76+
}
77+
6478
version, err := m.getCudaVersion()
6579
if err != nil {
6680
return nil, fmt.Errorf("failed to get CUDA version: %v", err)

0 commit comments

Comments
 (0)