npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

npu-detect

v1.0.1

Published

Cross-platform NPU (Neural Processing Unit) detection for JavaScript — Node.js + Browser (WebNN)

Downloads

187

Readme

npu-detect

Cross-platform NPU (Neural Processing Unit) detection for JavaScript.

Works in Node.js (server-side, shells out to OS tools) and Browsers (client-side, via the WebNN API).

Why?

You can query CPU info with os.cpus() and GPU info with navigator.gpu — but there's no equivalent for NPUs. This library fills that gap.

Install

npm install npu-detect

Quick Start

Node.js

const { detectNPU, hasNPU, npuSummary } = require('npu-detect');

// Full detection with details
const info = await detectNPU();
console.log(info);
// {
//   detected: true,
//   platform: 'darwin',
//   devices: [{ name: 'Apple Neural Engine (ANE)', cores: 16, ... }],
//   cpuHeuristic: { likely: true, vendor: 'Apple', npuName: 'Apple Neural Engine' },
//   ...
// }

// Quick boolean
const has = await hasNPU(); // true

// One-liner summary
const summary = await npuSummary(); // "NPU detected: Apple Neural Engine (ANE)"

Browser

import { detectNPU, hasNPU } from 'npu-detect/browser';

const info = await detectNPU({ benchmark: true });
console.log(info);
// {
//   webnnSupported: true,
//   npuAvailable: true,
//   devices: {
//     npu: { available: true, benchmark: { functional: true, execLatencyMs: 0.4 } },
//     cpu: { available: true, ... },
//     gpu: { available: true, ... },
//   },
//   ...
// }

CLI

npx npu-detect
npx npu-detect --verbose
npx npu-detect --json

How It Works

Node.js Detection (per platform)

| Platform | Method | |----------|--------| | Linux | Checks /dev/accel/* devices, lspci for NPU-class hardware, lsmod for intel_vpu/amdxdna kernel modules, sysfs for NPU frequency | | Windows | Queries Device Manager's "Neural processors" class via PowerShell (Get-PnpDevice), falls back to WMI | | macOS | Uses ioreg to find AppleNeuralEngine, infers ANE core count and TOPS from chip model, reads powermetrics for ANE power (requires root) | | All | CPU model string heuristic to identify known NPU-equipped processors (Intel Core Ultra, Snapdragon X, Ryzen AI, Apple M-series, etc.) |

Browser Detection

Uses the W3C Web Neural Network API (navigator.ml):

  1. Checks if navigator.ml exists
  2. Attempts navigator.ml.createContext({ deviceType: 'npu' }) — success means NPU is available
  3. Optionally runs a minimal add-two-matrices computation graph to verify the device is functional
  4. Also probes cpu and gpu device types for comparison

Note: WebNN requires Chrome/Edge with the flag chrome://flags/#web-machine-learning-neural-network enabled, or Edge with --disable_webnn_for_npu=0 for NPU specifically.

Supported NPU Hardware

| Vendor | NPU | Detection | |--------|-----|-----------| | Intel | AI Boost (Core Ultra / Meteor Lake, Arrow Lake, Lunar Lake) | Linux: intel_vpu module + /dev/accel/accel0. Windows: Device Manager. | | AMD | XDNA / XDNA2 (Ryzen AI, Hawk Point, Strix Point) | Linux: amdxdna module. Windows: Device Manager. | | Qualcomm | Hexagon (Snapdragon X Elite/Plus) | Windows: Device Manager. Browser: WebNN. | | Apple | Neural Engine (M1–M4, A11–A19) | macOS: ioreg + chip identification. |

API Reference

Node.js (npu-detect)

detectNPU(options?): Promise<NPUDetectionResult>

Full detection. Options:

  • cpuHeuristic (boolean, default true) — also check CPU model string
  • verbose (boolean, default false) — include raw OS command output

hasNPU(): Promise<boolean>

Quick boolean — confirmed NPU present?

npuSummary(): Promise<string>

Human-readable one-liner.

Browser (npu-detect/browser)

detectNPU(options?): Promise<BrowserNPUDetectionResult>

Full browser detection. Options:

  • benchmark (boolean, default false) — run a test computation on each device
  • probeAll (boolean, default true) — also probe CPU and GPU

hasNPU(): Promise<boolean>

Quick boolean — NPU available via WebNN?

probeDevice(deviceType): Promise<{available, error?, context?}>

Low-level probe for a specific WebNN device type.

benchmarkDevice(deviceType): Promise<{functional, buildLatencyMs?, execLatencyMs?, error?}>

Run a minimal computation on a device and measure latency.

Caveats

  • Linux: NPU detection requires the kernel module to be loaded and /dev/accel/ to be populated. Some sysfs paths require root.
  • Windows: PowerShell queries may be slow (~1-2s). The "NeuralProcessor" PnP class requires up-to-date drivers.
  • macOS: Apple provides almost no public API for ANE introspection. Detection relies on ioreg and chip identification. powermetrics requires sudo.
  • Browser: WebNN is still an emerging standard. NPU support requires specific browser flags and up-to-date GPU/NPU drivers.
  • CPU Heuristic: The CPU model string check is a "best guess" — it tells you the CPU should have an NPU, not that it's accessible.

License

MIT