Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pkg/nvlib/info/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ type PropertyExtractor interface {
HasDXCore() (bool, string)
HasNvml() (bool, string)
HasTegraFiles() (bool, string)
// Deprecated: Use HasTegraFiles instead.
IsTegraSystem() (bool, string)
// Deprecated: Use HasOnlyIntegratedGPUs
UsesOnlyNVGPUModule() (bool, string)
HasOnlyIntegratedGPUs() (bool, string)
HasAnIntegratedGPU() (bool, string)
}
36 changes: 20 additions & 16 deletions pkg/nvlib/info/property-extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,20 @@ func (i *propertyExtractor) HasTegraFiles() (bool, string) {
return false, fmt.Sprintf("%v has no 'tegra' prefix", tegraFamilyFile)
}

// UsesOnlyNVGPUModule checks whether the only the nvgpu module is used.
//
// Deprecated: UsesOnlyNVGPUModule is deprecated, use HasOnlyIntegratedGPUs instead.
func (i *propertyExtractor) UsesOnlyNVGPUModule() (uses bool, reason string) {
return i.HasOnlyIntegratedGPUs()
}

// HasOnlyIntegratedGPUs checks whether all GPUs are iGPUs that use NVML.
// HasAnIntegratedGPU checks whether any of the GPUs reported by NVML is an
// integrated GPU.
//
// As of Orin-based systems iGPUs also support limited NVML queries.
// In the absence of a robust API, we rely on heuristics to make this decision.
// In the absence of a robust API, we rely on heuristics based on the device
// name to make this decision.
//
// The following device names are checked:
// Devices with the following names are considered integrated GPUs:
//
// GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
// GPU 0: NVIDIA Thor (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
//
// This function returns true if ALL devices are detected as iGPUs.
func (i *propertyExtractor) HasOnlyIntegratedGPUs() (uses bool, reason string) {
// (Where this shows the nvidia-smi -L output on these systems).
func (i *propertyExtractor) HasAnIntegratedGPU() (uses bool, reason string) {
// We ensure that this function never panics
defer func() {
if err := recover(); err != nil {
Expand Down Expand Up @@ -144,14 +139,23 @@ func (i *propertyExtractor) HasOnlyIntegratedGPUs() (uses bool, reason string) {
}

for _, name := range names {
if !isIntegratedGPUName(name) {
return false, fmt.Sprintf("device %q does not use nvgpu module", name)
if IsIntegratedGPUName(name) {
return true, fmt.Sprintf("device %q is an integrated GPU", name)
}
}
return true, "all devices use nvgpu module"
return false, "no integrated GPUs found"
}

func isIntegratedGPUName(name string) bool {
// IsIntegratedGPUName checks whether the specified device name is associated
// with a known integrated GPU.
//
// Devices with the following names are considered integrated GPUs:
//
// GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
// GPU 0: NVIDIA Thor (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
//
// (Where this shows the nvidia-smi -L output on these systems).
func IsIntegratedGPUName(name string) bool {
if strings.Contains(name, "(nvgpu)") {
return true
}
Expand Down
154 changes: 40 additions & 114 deletions pkg/nvlib/info/property-extractor_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/nvlib/info/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func (p platformResolver) ResolvePlatform() Platform {
hasNVML, reason := p.propertyExtractor.HasNvml()
p.logger.Debugf("Is NVML-based system? %v: %v", hasNVML, reason)

hasOnlyIntegratedGPUs, reason := p.propertyExtractor.HasOnlyIntegratedGPUs()
p.logger.Debugf("Has only integrated GPUs? %v: %v", hasOnlyIntegratedGPUs, reason)
hasAnIntegratedGPU, reason := p.propertyExtractor.HasAnIntegratedGPU()
p.logger.Debugf("Has an integrated GPU? %v: %v", hasAnIntegratedGPU, reason)

switch {
case hasDXCore:
return PlatformWSL
case (hasTegraFiles && !hasNVML), hasOnlyIntegratedGPUs:
case (hasTegraFiles && !hasNVML), hasAnIntegratedGPU:
return PlatformTegra
case hasNVML:
return PlatformNVML
Expand Down
28 changes: 14 additions & 14 deletions pkg/nvlib/info/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (

func TestResolvePlatform(t *testing.T) {
testCases := []struct {
platform string
hasTegraFiles bool
hasDXCore bool
hasNVML bool
hasOnlyIntegratedGPUs bool
expected string
platform string
hasTegraFiles bool
hasDXCore bool
hasNVML bool
hasAnIntegratedGPU bool
expected string
}{
{
platform: "auto",
Expand Down Expand Up @@ -59,12 +59,12 @@ func TestResolvePlatform(t *testing.T) {
expected: "nvml",
},
{
platform: "auto",
hasDXCore: false,
hasTegraFiles: true,
hasNVML: true,
hasOnlyIntegratedGPUs: true,
expected: "tegra",
platform: "auto",
hasDXCore: false,
hasTegraFiles: true,
hasNVML: true,
hasAnIntegratedGPU: true,
expected: "tegra",
},
{
platform: "nvml",
Expand Down Expand Up @@ -97,8 +97,8 @@ func TestResolvePlatform(t *testing.T) {
HasTegraFilesFunc: func() (bool, string) {
return tc.hasTegraFiles, ""
},
HasOnlyIntegratedGPUsFunc: func() (bool, string) {
return tc.hasOnlyIntegratedGPUs, ""
HasAnIntegratedGPUFunc: func() (bool, string) {
return tc.hasAnIntegratedGPU, ""
},
}),
WithPlatform(Platform(tc.platform)),
Expand Down