File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,10 @@ func (l *nvcdilib) getCudaVersionNvml() (string, error) {
263263}
264264
265265func (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 {
Original file line number Diff line number Diff 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.
6364func (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 )
You can’t perform that action at this time.
0 commit comments