nvsandboxutils: Add usage of GetGpuResource and GetFileContent APIs

This change adds a new discoverer for Sandboxutils to report the file
system paths and associated symbolic links using GetGpuResource and
GetFileContent APIs. Both GPU and MIG devices are supported. If the
Sandboxutils discoverer fails, the NVML discoverer is used to report
the file system information.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
Signed-off-by: Huy Nguyen <huyn@nvidia.com>
Signed-off-by: Sananya Majumder <sananyam@nvidia.com>
This commit is contained in:
Sananya Majumder
2024-09-24 10:05:14 -07:00
parent 7b770f63c3
commit 563db0e0be
9 changed files with 536 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ package dgpu
import (
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
"github.com/NVIDIA/nvidia-container-toolkit/internal/nvcaps"
"github.com/NVIDIA/nvidia-container-toolkit/internal/nvsandboxutils"
)
type options struct {
@@ -26,10 +27,13 @@ type options struct {
devRoot string
nvidiaCDIHookPath string
isMigDevice bool
// migCaps stores the MIG capabilities for the system.
// If MIG is not available, this is nil.
migCaps nvcaps.MigCaps
migCapsError error
nvsandboxutilslib nvsandboxutils.Interface
}
type Option func(*options)
@@ -61,3 +65,10 @@ func WithMIGCaps(migCaps nvcaps.MigCaps) Option {
l.migCaps = migCaps
}
}
// WithNvsandboxuitilsLib sets the nvsandboxutils library implementation.
func WithNvsandboxuitilsLib(nvsandboxutilslib nvsandboxutils.Interface) Option {
return func(l *options) {
l.nvsandboxutilslib = nvsandboxutilslib
}
}