@infernetprotocol/gpu 0.1.58 → 0.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/detect.js +27 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infernetprotocol/gpu",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "description": "Local hardware detection for the Infernet Protocol — GPUs (NVIDIA, AMD, Apple Silicon) via native tooling, plus CPUs / RAM / arch via node:os. Pure-JS for the CPU side, vendor-CLI shell-out for GPUs.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/detect.js CHANGED
@@ -248,17 +248,37 @@ async function detectLspciFallback() {
248
248
  lastDiagnostics.lspci = 'lspci ran but no VGA/3D/Display devices found';
249
249
  return [];
250
250
  }
251
- return lines.map((line, i) => parseLspciLine(line, i));
251
+ return parseLspciLines(lines);
252
252
  }
253
253
  const lines = result.stdout.split('\n').filter((l) => l.trim().length > 0);
254
254
  if (lines.length === 0) {
255
255
  lastDiagnostics.lspci = 'lspci ran but reported no VGA devices';
256
256
  return [];
257
257
  }
258
- return lines.map((line, i) => parseLspciLine(line, i));
258
+ return parseLspciLines(lines);
259
259
  }
260
260
 
261
- function parseLspciLine(line, index) {
261
+ // Display adapters that are never an inference GPU: hypervisor-emulated VGA
262
+ // (QEMU std-vga 1234, Cirrus 1013, VMware 15ad, VirtualBox 80ee, virtio 1af4,
263
+ // QXL 1b36, Hyper-V 1414) and server BMC framebuffers (ASPEED 1a03, Matrox
264
+ // G200 102b). Matched by PCI vendor id (-nn) or vendor name (-mm).
265
+ const NON_COMPUTE_VGA_IDS = /\[(1234|1013|15ad|80ee|1af4|1b36|1414|1a03|102b):[0-9a-f]{4}\]/i;
266
+ const NON_COMPUTE_VGA_NAMES = /\b(vendor 1234|qemu|bochs|cirrus logic|vmware|virtualbox|innotek|virtio|qxl|hyper-v|aspeed|matrox)\b/i;
267
+
268
+ export function isNonComputeDisplay(line) {
269
+ return NON_COMPUTE_VGA_IDS.test(line) || NON_COMPUTE_VGA_NAMES.test(line);
270
+ }
271
+
272
+ export function parseLspciLines(lines) {
273
+ const real = lines.filter((l) => !isNonComputeDisplay(l));
274
+ if (real.length === 0) {
275
+ lastDiagnostics.lspci = 'lspci found only virtual/BMC display adapters (no compute GPU)';
276
+ return [];
277
+ }
278
+ return real.map((line, i) => parseLspciLine(line, i));
279
+ }
280
+
281
+ export function parseLspciLine(line, index) {
262
282
  // -mm output: BDF "Vendor" "Device" "Subsys" ...
263
283
  // -nn output: BDF Class: Vendor Device [vendor:dev]
264
284
  let vendor = null;
@@ -267,10 +287,10 @@ function parseLspciLine(line, index) {
267
287
  if (lower.includes('nvidia')) vendor = 'nvidia';
268
288
  else if (lower.includes('amd') || lower.includes('ati ')) vendor = 'amd';
269
289
  else if (lower.includes('intel')) vendor = 'intel';
270
- // Best-effort model extraction: take whatever's between the first
271
- // and second double-quote (works for -mm format).
272
- const m = line.match(/"([^"]+)"\s+"([^"]+)"/);
273
- if (m) model = `${m[1]} ${m[2]}`.trim();
290
+ // -mm format: the quoted fields are class, vendor, device — the model
291
+ // is vendor + device, not the class name.
292
+ const q = [...line.matchAll(/"([^"]*)"/g)].map((x) => x[1]);
293
+ if (q.length >= 3) model = `${q[1]} ${q[2]}`.trim();
274
294
  return {
275
295
  vendor: vendor ?? 'unknown',
276
296
  index,