Skip to content

Commit

Permalink
Use go-nvlib to resolve platform
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Apr 22, 2024
1 parent 58a2e8d commit c5bb025
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions internal/plugin/manager/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func New(opts ...Option) (Interface, error) {
}

if m.infolib == nil {
m.infolib = info.New()
m.infolib = info.New(
info.WithNvmlLib(m.nvmllib),
)
}

mode, err := m.resolveMode()
Expand Down Expand Up @@ -95,20 +97,9 @@ func New(opts ...Option) (Interface, error) {
}

func (m *manager) resolveMode() (string, error) {
// logWithReason logs the output of the has* / is* checks from the info.Interface
logWithReason := func(f func() (bool, string), tag string) bool {
is, reason := f()
if !is {
tag = "non-" + tag
}
klog.Infof("Detected %v platform: %v", tag, reason)
return is
}

hasNVML := logWithReason(m.infolib.HasNvml, "NVML")
isTegra := logWithReason(m.infolib.IsTegraSystem, "Tegra")
platform := m.infolib.ResolvePlatform()

if !hasNVML && !isTegra {
if platform != info.PlatformNVML && platform != info.PlatformTegra {
klog.Error("Incompatible platform detected")
klog.Error("If this is a GPU node, did you configure the NVIDIA Container Toolkit?")
klog.Error("You can check the prerequisites at: https://github.com/NVIDIA/k8s-device-plugin#prerequisites")
Expand All @@ -120,14 +111,5 @@ func (m *manager) resolveMode() (string, error) {
return "null", nil
}

// The NVIDIA container stack does not yet support the use of integrated AND discrete GPUs on the same node.
if isTegra {
if hasNVML {
klog.Warning("Disabling Tegra-based resources on NVML system")
return "nvml", nil
}
return "tegra", nil
}

return "nvml", nil
return string(platform), nil
}

0 comments on commit c5bb025

Please sign in to comment.