An NVIDIA card with no driver is reported, not onboarded as a CPU node
CI / test (push) Failing after 9m12s

The agent found GPUs through nvidia-smi alone, so a machine whose driver
was never installed looked exactly like one with no card and joined
quietly as a CPU node. Only init looked at the PCI bus.

The host discovery now reads the bus too (vendor 0x10de, class 0x03) and
carries it to the control plane. The doctor fails the pre-install checks
on a card without a driver, with the install and the reboot named, and
tells a driver that is installed but not loaded (Secure Boot, nouveau)
apart from a missing one. A node already in shows the warning in ctl
nodes and the console. init uses the same check.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Fable 5.1 committed 2026-11-19 12:29:02 +01:00
1 parent a53b2f4be9
commit c2fedeb326
12 files changed
+138 -26

No files matched your search

+1 -1
View File
@@ -596,7 +596,7 @@ func (a *Agent) session(ctx context.Context, server string) error {
a.forgetSent()
reg.Host = &llmgwv1.Host{
OsId: h.OSID, OsVersion: h.OSVersion, OsCodename: h.OSCodename,
Arch: h.Arch, CpuFlags: h.CPUFlags, NvidiaDriver: h.NVIDIADriver,
Arch: h.Arch, CpuFlags: h.CPUFlags, NvidiaDriver: h.NVIDIADriver, NvidiaDevice: h.NVIDIADevice,
// What is measured by now, not what the startup scan found before
// the measurement ended: a reconnect would otherwise say 0.
MemBandwidthGbs: a.memBandwidth().All,
+31
View File
@@ -3,6 +3,7 @@ package discovery
import (
"bufio"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
@@ -28,6 +29,10 @@ type Host struct {
CPUFlags []string `json:"cpu_flags,omitempty"`
// NVIDIADriver is the loaded driver's version, empty when there is none.
NVIDIADriver string `json:"nvidia_driver,omitempty"`
// NVIDIADevice is whether an NVIDIA display controller is on the PCI bus,
// driver or not. True with NVIDIADriver empty is a card without a driver:
// a machine that would otherwise serve on CPU with nothing saying why.
NVIDIADevice bool `json:"nvidia_device,omitempty"`
// MinComputeCapability is the oldest GPU's, 0 when there are none or it
// is not known. Not read here but from the GPU inventory, by the agent.
MinComputeCapability float64 `json:"min_compute_capability,omitempty"`
@@ -75,9 +80,35 @@ func DiscoverHost() Host {
h.Arch = debianArch(runtime.GOARCH)
h.CPUFlags = cpuFlagsFrom("/proc/cpuinfo")
h.NVIDIADriver = nvidiaDriverFrom("/proc/driver/nvidia/version")
h.NVIDIADevice = HasNVIDIADevice()
return h
}
// CardWithoutDriver reports an NVIDIA card on the PCI bus with no driver
// loaded: a node that looks like a CPU node to nvidia-smi and is not one.
func (h Host) CardWithoutDriver() bool { return h.NVIDIADevice && h.NVIDIADriver == "" }
// HasNVIDIADevice reports an NVIDIA display or 3D controller on the PCI bus,
// read from sysfs, which needs no driver.
func HasNVIDIADevice() bool { return hasNVIDIADeviceIn("/sys/bus/pci/devices") }
func hasNVIDIADeviceIn(root string) bool {
vendors, _ := filepath.Glob(filepath.Join(root, "*", "vendor"))
for _, v := range vendors {
b, err := os.ReadFile(v) //nolint:gosec // sysfs
if err != nil || strings.TrimSpace(string(b)) != "0x10de" {
continue
}
class, _ := os.ReadFile(filepath.Join(filepath.Dir(v), "class")) //nolint:gosec // sysfs
// 0x03xxxx is a display or 3D controller; NVIDIA also makes bridges
// and audio devices.
if strings.HasPrefix(strings.TrimSpace(string(class)), "0x03") {
return true
}
}
return false
}
func hostFromOSRelease(path string) Host {
var h Host
f, err := os.Open(path) //nolint:gosec // a fixed system path
@@ -23,3 +23,35 @@ func TestNVIDIADriverFrom(t *testing.T) {
}
}
}
func TestACardOnTheBusIsSeenWithoutADriver(t *testing.T) {
root := t.TempDir()
dev := func(name, vendor, class string) {
d := filepath.Join(root, name)
if err := os.MkdirAll(d, 0o750); err != nil {
t.Fatal(err)
}
_ = os.WriteFile(filepath.Join(d, "vendor"), []byte(vendor+"\n"), 0o600)
_ = os.WriteFile(filepath.Join(d, "class"), []byte(class+"\n"), 0o600)
}
dev("0000:00:1f.0", "0x8086", "0x060100") // the chipset
if hasNVIDIADeviceIn(root) {
t.Fatal("a machine with no NVIDIA device said it had one")
}
dev("0000:01:00.1", "0x10de", "0x040300") // the card's HDMI audio alone is not a GPU
if hasNVIDIADeviceIn(root) {
t.Fatal("NVIDIA's audio device was taken for a GPU")
}
dev("0000:01:00.0", "0x10de", "0x030000")
if !hasNVIDIADeviceIn(root) {
t.Fatal("a VGA controller of NVIDIA's was not seen")
}
h := Host{NVIDIADevice: true}
if !h.CardWithoutDriver() {
t.Error("a card with no driver version is a card without a driver")
}
h.NVIDIADriver = "580.82.07"
if h.CardWithoutDriver() {
t.Error("a card with a driver was reported as without one")
}
}
+1 -19
View File
@@ -329,7 +329,7 @@ func (in *serverInit) ensureNode(ctx context.Context) (string, error) {
if classes, n := gpuClasses(ctx); n > 0 {
in.kept("%d NVIDIA GPU(s) here: %s — the node will use them", n, strings.Join(classes, ", "))
} else if hasNVIDIADevice() {
} else if discovery.HasNVIDIADevice() {
fmt.Fprintf(in.out, " !! an NVIDIA card is on the PCI bus but nvidia-smi does not answer: "+
"install the driver and run init again to serve on it; until then this node is CPU only\n")
} else {
@@ -434,24 +434,6 @@ labels:
return nodeID, nil
}
// hasNVIDIADevice reports an NVIDIA card on the PCI bus, driver or not, so a
// machine whose GPU is invisible for want of a driver says so instead of
// quietly serving on CPU.
func hasNVIDIADevice() bool {
vendors, _ := filepath.Glob("/sys/bus/pci/devices/*/vendor")
for _, v := range vendors {
b, err := os.ReadFile(v)
if err == nil && strings.TrimSpace(string(b)) == "0x10de" {
class, _ := os.ReadFile(filepath.Join(filepath.Dir(v), "class"))
// 0x03xxxx is a display or 3D controller; NVIDIA also makes bridges.
if strings.HasPrefix(strings.TrimSpace(string(class)), "0x03") {
return true
}
}
}
return false
}
// --- the starter model ---
// starterModel is the catalog entry: a GPU profile first when there is a card,
+4
View File
@@ -754,6 +754,10 @@ func (a *API) Nodes() []NodeView {
}
if h := n.Host; h.OSID != "" {
v.OS = strings.TrimSpace(h.OSID + " " + h.OSVersion + " " + h.Arch)
if h.CardWithoutDriver() {
v.Warnings = append(v.Warnings, "an NVIDIA card is on the PCI bus but no driver is loaded: "+
"this node serves on CPU only (install the driver, reboot, check nvidia-smi, restart the agent)")
}
if h.Arch == "amd64" && !h.HasCPUFlag("avx2") {
v.Warnings = append(v.Warnings, "no AVX2: inference runs several times slower "+
"(a VM needs CPU type \"host\")")
+1
View File
@@ -36,6 +36,7 @@ func NodeFromRegister(r *llmgwv1.Register) inventory.Node {
n.Host = discovery.Host{
OSID: h.GetOsId(), OSVersion: h.GetOsVersion(), OSCodename: h.GetOsCodename(),
Arch: h.GetArch(), CPUFlags: h.GetCpuFlags(), NVIDIADriver: h.GetNvidiaDriver(),
NVIDIADevice: h.GetNvidiaDevice(),
MemBandwidthGBs: h.GetMemBandwidthGbs(), MemBandwidthCoreGBs: h.GetMemBandwidthCoreGbs(),
}
}
+14 -1
View File
@@ -122,6 +122,10 @@ type Options struct {
}
// Collect reads the node.
// driverFix is what to do about a card with no working driver.
const driverFix = "install the NVIDIA driver the card needs (on Ubuntu: apt-get install nvidia-driver-580-open), reboot, " +
"and nvidia-smi must list it; then add the node again, or restart its agent if it was added already"
func Collect(ctx context.Context, o Options) Facts {
f := Facts{At: time.Now().UTC(), Modules: map[string]bool{}, Engines: map[string]string{}}
f.Hostname, _ = os.Hostname()
@@ -372,10 +376,19 @@ func Evaluate(f Facts) []Finding {
// --- GPUs ---
switch {
case !f.SMIFound && f.Host.NVIDIADevice:
add(Fail, "gpu", "an NVIDIA card is on the PCI bus but no driver is installed: this node would serve on CPU only",
driverFix)
case !f.SMIFound:
add(Info, "gpu", "no nvidia-smi: a CPU node, or the driver is not installed", "")
add(Info, "gpu", "no nvidia-smi: a CPU node", "")
case f.GPUError != "" && f.Host.CardWithoutDriver():
add(Fail, "gpu", "an NVIDIA card is on the PCI bus but its driver is not loaded: "+f.GPUError,
"reboot if the driver was just installed; with Secure Boot on, the module must be signed (mokutil --sb-state); "+
"check that nouveau is not holding the card (lsmod | grep nouveau)")
case f.GPUError != "":
add(Fail, "gpu", "nvidia-smi fails: "+f.GPUError, "check the driver: run nvidia-smi by hand")
case len(f.GPUs) == 0 && f.Host.NVIDIADevice:
add(Fail, "gpu", "an NVIDIA card is on the PCI bus but nvidia-smi reports no GPUs", driverFix)
case len(f.GPUs) == 0:
add(Warn, "gpu", "nvidia-smi is installed but reports no GPUs", "")
default:
+24
View File
@@ -276,3 +276,27 @@ func TestTheNodeAndItsFabricsAreReadySeparately(t *testing.T) {
t.Errorf("%+v", r)
}
}
func TestACardWithoutADriverIsAFailureNotACPUNode(t *testing.T) {
// The mistake this guards: a GPU node whose driver was never installed
// onboarded quietly as a CPU node, with nothing anywhere saying why.
f := healthy()
f.SMIFound, f.GPUs, f.GPUError = false, nil, ""
f.Host.NVIDIADevice, f.Host.NVIDIADriver = true, ""
fs := Evaluate(f)
has(t, fs, Fail, "an NVIDIA card is on the PCI bus but no driver is installed")
f.Host.NVIDIADevice = false
fs = Evaluate(f)
if bad := levels(fs, Fail); len(bad) > 0 {
t.Errorf("a plain CPU node was faulted: %v", bad)
}
has(t, fs, Info, "no nvidia-smi: a CPU node")
// nvidia-smi installed, the module not loaded: the message points at the
// usual reasons rather than at a generic "run nvidia-smi".
f.SMIFound, f.GPUError = true, "running nvidia-smi: exit status 9"
f.Host.NVIDIADevice = true
fs = Evaluate(f)
has(t, fs, Fail, "its driver is not loaded")
}