DirectML

WebNN Setup Guide

Enabling WebNN for GPU

  1. Requires Windows 11 v21H2 (DML 1.6.0) or higher and a GPU, for support of "expand" and "layerNormalization" ops. See WebNN implementation status
  2. Requires Chromium desktop (e.g. Chrome, Edge) 129 or higher
  3. Enable chrome://flags/#web-machine-learning-neural-network and relaunch the browser
  4. Enable graphics/hardware acceleration browser setting
  5. Make sure your system graphics settings for the browser uses high performance / discrete GPU

Enabling WebNN for NPU

To get started with WebNN NPU on DirectML compatible devices you will need:
  • Windows 11, version 24H2 or newer
  • Insider version of Edge (exact instructions provided below)
  • The latest driver from our WebNN NPU Partners:
    • Intel® Core™ Ultra NPU Driver for Windows
    • Qualcomm® Hexagon NPU Driver Package for windows
Enabling Insider version of Edge:
  1. Microsoft Edge Canary or Dev Channel with WebNN flag enabled in about:flags
    1. Download from https://www.microsoft.com/en-us/edge/download/insider
    2. Run installer
    3. Navigate to about://flags
    4. Search for Enables WebNN API and change it to Enabled
    5. Exit browser
  2. Download DirectML redistributable
    1. Download DirectML from https://www.nuget.org/packages/Microsoft.AI.DirectML/1.15.2
    2. Rename microsoft.ai.directml.1.15.2.nupkg to microsoft.ai.directml.1.15.2.nupkg.zip and extract it
  3. Copy microsoft.ai.directml.1.15.2.nupkg.zip\bin\<arch>-win\directml.dll to the appropriate directory
    (replace with x64 on Intel devices and arm64 on Qualcomm devices)
    1. Edge Dev: C:\Program Files (x86)\Microsoft\Edge Dev\Application\129.0.2779.0\
      1. When the dialog asks for Administrator permission, choose Continue
    2. Edge Canary: %LOCALAPPDATA%\Microsoft\Edge SxS\Application\129.0.2779.0\
    3. Note the following on copying Directml.dll to Edge directory
      1. The version-specific directory (129.0.2779.0) may differ on your machine
      2. New versions of Edge may require directml.dll to be recopied to the directory
  4. Launch Edge insider
    1. Open terminal and change your working directory to the Edge Insider build:
      • If using Edge Dev: C:\Program Files (x86)\Microsoft\Edge Dev\Application
      • If using Edge Canary: %LOCALAPPDATA%\Microsoft\Edge SxS\Application
    2. .\msedge.exe --use-redist-dml --disable_webnn_for_npu=0 --disable-gpu-sandbox
  • Direct Machine Learning (DirectML)
  • ONNX Runtime Web
  • ONNX
  • WebNN API
  • WebNN Installation Guide