Skip to content

Commit eda6327

Browse files
committed
Resolve a tegra platform for a single iGPU
Instead of requiring that all GPUs on an Tegra platform with NVML be iGPUs, we resolve it as a tegra platform if at least one device is an iGPU. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 9a6788d commit eda6327

File tree

5 files changed

+78
-152
lines changed

5 files changed

+78
-152
lines changed

pkg/nvlib/info/api.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,5 @@ type PropertyExtractor interface {
3535
HasDXCore() (bool, string)
3636
HasNvml() (bool, string)
3737
HasTegraFiles() (bool, string)
38-
// Deprecated: Use HasTegraFiles instead.
39-
IsTegraSystem() (bool, string)
40-
// Deprecated: Use HasOnlyIntegratedGPUs
41-
UsesOnlyNVGPUModule() (bool, string)
42-
HasOnlyIntegratedGPUs() (bool, string)
38+
HasAnIntegratedGPU() (bool, string)
4339
}

pkg/nvlib/info/property-extractor.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,20 @@ func (i *propertyExtractor) HasTegraFiles() (bool, string) {
9090
return false, fmt.Sprintf("%v has no 'tegra' prefix", tegraFamilyFile)
9191
}
9292

93-
// UsesOnlyNVGPUModule checks whether the only the nvgpu module is used.
94-
//
95-
// Deprecated: UsesOnlyNVGPUModule is deprecated, use HasOnlyIntegratedGPUs instead.
96-
func (i *propertyExtractor) UsesOnlyNVGPUModule() (uses bool, reason string) {
97-
return i.HasOnlyIntegratedGPUs()
98-
}
99-
100-
// HasOnlyIntegratedGPUs checks whether all GPUs are iGPUs that use NVML.
93+
// HasAnIntegratedGPU checks whether any of the GPUs reported by NVML is an
94+
// integrated GPU.
10195
//
10296
// As of Orin-based systems iGPUs also support limited NVML queries.
103-
// In the absence of a robust API, we rely on heuristics to make this decision.
97+
// In the absence of a robust API, we rely on heuristics based on the device
98+
// name to make this decision.
10499
//
105-
// The following device names are checked:
100+
// Devices with the following names are considered integrated GPUs:
106101
//
107102
// GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
108103
// GPU 0: NVIDIA Thor (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
109104
//
110-
// This function returns true if ALL devices are detected as iGPUs.
111-
func (i *propertyExtractor) HasOnlyIntegratedGPUs() (uses bool, reason string) {
105+
// (Where this shows the nvidia-smi -L output on these systems).
106+
func (i *propertyExtractor) HasAnIntegratedGPU() (uses bool, reason string) {
112107
// We ensure that this function never panics
113108
defer func() {
114109
if err := recover(); err != nil {
@@ -144,14 +139,23 @@ func (i *propertyExtractor) HasOnlyIntegratedGPUs() (uses bool, reason string) {
144139
}
145140

146141
for _, name := range names {
147-
if !isIntegratedGPUName(name) {
148-
return false, fmt.Sprintf("device %q does not use nvgpu module", name)
142+
if IsIntegratedGPUName(name) {
143+
return true, fmt.Sprintf("device %q is an integrated GPU", name)
149144
}
150145
}
151-
return true, "all devices use nvgpu module"
146+
return false, "no integrated GPUs found"
152147
}
153148

154-
func isIntegratedGPUName(name string) bool {
149+
// IsIntegratedGPUName checks whether the specified device name is associated
150+
// with a known integrated GPU.
151+
//
152+
// Devices with the following names are considered integrated GPUs:
153+
//
154+
// GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
155+
// GPU 0: NVIDIA Thor (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
156+
//
157+
// (Where this shows the nvidia-smi -L output on these systems).
158+
func IsIntegratedGPUName(name string) bool {
155159
if strings.Contains(name, "(nvgpu)") {
156160
return true
157161
}

pkg/nvlib/info/property-extractor_mock.go

Lines changed: 40 additions & 114 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/nvlib/info/resolver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ func (p platformResolver) ResolvePlatform() Platform {
4848
hasNVML, reason := p.propertyExtractor.HasNvml()
4949
p.logger.Debugf("Is NVML-based system? %v: %v", hasNVML, reason)
5050

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

5454
switch {
5555
case hasDXCore:
5656
return PlatformWSL
57-
case (hasTegraFiles && !hasNVML), hasOnlyIntegratedGPUs:
57+
case (hasTegraFiles && !hasNVML), hasAnIntegratedGPU:
5858
return PlatformTegra
5959
case hasNVML:
6060
return PlatformNVML

pkg/nvlib/info/resolver_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import (
2525

2626
func TestResolvePlatform(t *testing.T) {
2727
testCases := []struct {
28-
platform string
29-
hasTegraFiles bool
30-
hasDXCore bool
31-
hasNVML bool
32-
hasOnlyIntegratedGPUs bool
33-
expected string
28+
platform string
29+
hasTegraFiles bool
30+
hasDXCore bool
31+
hasNVML bool
32+
hasAnIntegratedGPU bool
33+
expected string
3434
}{
3535
{
3636
platform: "auto",
@@ -59,12 +59,12 @@ func TestResolvePlatform(t *testing.T) {
5959
expected: "nvml",
6060
},
6161
{
62-
platform: "auto",
63-
hasDXCore: false,
64-
hasTegraFiles: true,
65-
hasNVML: true,
66-
hasOnlyIntegratedGPUs: true,
67-
expected: "tegra",
62+
platform: "auto",
63+
hasDXCore: false,
64+
hasTegraFiles: true,
65+
hasNVML: true,
66+
hasAnIntegratedGPU: true,
67+
expected: "tegra",
6868
},
6969
{
7070
platform: "nvml",
@@ -97,8 +97,8 @@ func TestResolvePlatform(t *testing.T) {
9797
HasTegraFilesFunc: func() (bool, string) {
9898
return tc.hasTegraFiles, ""
9999
},
100-
HasOnlyIntegratedGPUsFunc: func() (bool, string) {
101-
return tc.hasOnlyIntegratedGPUs, ""
100+
HasAnIntegratedGPUFunc: func() (bool, string) {
101+
return tc.hasAnIntegratedGPU, ""
102102
},
103103
}),
104104
WithPlatform(Platform(tc.platform)),

0 commit comments

Comments
 (0)