Skip to content

Commit

Permalink
re-write the webnn installation guides
Browse files Browse the repository at this point in the history
  • Loading branch information
mingmingtasd committed Sep 9, 2024
1 parent ac9f6ef commit d1215e2
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,43 @@ To get started, follow these steps:

### WebNN Installation Guides

WebNN requires a compatible browser to run, and Windows 11 v21H2 (DML 1.6.0) or higher for GPU. Try the latest Google Chrome Canary or Microsoft Edge Canary, which requires enabling WebNN functionality in the settings.
To get started with WebNN on Intel AI PCs you will need:
* Window 11, version 21H2 or newer
* It's recommended to install the latest [Intel® Arc™ & Iris® Xe Graphics](https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html) on Windows for improved WebNN compatibility and performance

1. Download the latest [Google Chrome Canary](https://www.google.com/chrome/canary/) or [Microsoft Edge Canary](https://www.microsoft.com/en-us/edge/download/insider) browser.
2. To enable WebNN, in your browser address bar, enter `chrome://flags`, and then press `Enter`. An Experiments page opens.
3. In the Search flags box, enter `webnn`. `Enables WebNN API` appears.
4. In the drop-down menu, select `Enabled`.
5. Relaunch your browser to run the samples on GPU or CPU. To run them on NPU, please continue following the additional steps below.
1. Download and install the latest [Chrome Canary](https://www.google.com/chrome/canary/) or [Edge Canary](https://www.microsoft.com/en-us/edge/download/insider?form=MA13FJ)
2. Navigate to `about://flags` in browser address bar
3. Search for `Enables WebNN API` and change it to "Enabled"
4. Exit browser

#### Running WebNN on CPU or GPU
1. Launch Chrome Canary or Edge Canary

#### Running WebNN on NPU
At present, the [image classification](https://webmachinelearning.github.io/webnn-samples/image_classification/) and [object detection](https://webmachinelearning.github.io/webnn-samples/object_detection/) samples support NPU.

* Install NPU driver:

For Intel® AI Boost NPU of Intel® Core™ Ultra processors, download and install the [latest Intel NPU driver](https://www.intel.com/content/www/us/en/download/794734/intel-npu-driver-windows.html).

* Google Chrome Canary:
1. Download the latest redistributable [Microsoft.AI.DirectML](https://www.nuget.org/packages/Microsoft.AI.DirectML/).
2. Extract the package and copy the DirectML.dll (e.g., \bin\x64-win\DirectML.dll) to the Chrome Canary’s version directory (e.g., %LOCALAPPDATA%\Google\Chrome SxS\Application\\"version number"). Note that Chrome Canary may automatically update to a new version, in which case DirectML.dll will need to be recopied to the directory.
3. Launch your browser in Windows Command Line:
```bash
"%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe" --use-redist-dml --disable_webnn_for_npu=0
```

* Microsoft Edge Canary:
1. Launch your browser in Windows Command Line:
```bash
"%LOCALAPPDATA%\Microsoft\Edge SxS\Application\msedge.exe" --disable_webnn_for_npu=0
```
2. For the first time you enable the `Enables WebNN API` flag, please wait a moment until the latest DirectML.dll is automatically downloaded into the Edge's user data directory (e.g., %LOCALAPPDATA%\Microsoft\Edge SxS\User Data\EdgeOnnxRuntimeDirectML\1.18.2.0) before trying the samples.
* Window 11, version 24H2 or newer
* It's recommended to install the latest [Intel® Core™ Ultra NPU Driver on Windows](https://www.intel.com/content/www/us/en/download/794734/intel-npu-driver-windows.html) for improved WebNN compatibility and performance
* **Google Chrome Canary:**
1. Download the latest redistributable [Microsoft.AI.DirectML](https://www.nuget.org/packages/Microsoft.AI.DirectML/1.15.2), rename the "microsoft.ai.directml.\<version>.nupkg" to "microsoft.ai.directml.\<version>.nupkg.zip" and extract it
2. Copy "\bin\x64-win\DirectML.dll" to "%LOCALAPPDATA%\Google\Chrome SxS\Application\\<version>\"
- "%LOCALAPPDATA%" means "C:\Users\<username>\AppData\Local\"
- Note that Chrome Canary frequently updates automatically. When this occurs, you'll need to recopy the DirectML.dll to the new version's directory
3. Launch Chrome Canary in Windows Command Line:
```bash
"%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe" --use-redist-dml --disable_webnn_for_npu=0
```

* **Microsoft Edge Canary:**
1. Ensure the DirectML.dll was downloaded automatically (may take several minutes):
- Launch Edge Canary
- Go to "%LOCALAPPDATA%\Microsoft\Edge SxS\User Data", check the "EdgeOnnxRuntimeDirectML\<version>\DirectML.dll" exists
- "%LOCALAPPDATA%" means "C:\Users\<username>\AppData\Local\"
- Exit Edge Canary
2. Launch Edge Canary in Windows Command Line:
```bash
"%LOCALAPPDATA%\Microsoft\Edge SxS\Application\msedge.exe" --disable_webnn_for_npu=0
```

* Notes:
1. There is an intermittent issue with the Intel NPU driver that causes failure of NPU adapter creation. The `WebNN(NPU)` backend button in the samples will be disabled with message "Unable to find a capable adapter". If you encounter this issue, please relaunch your browser and try again.
Expand Down

0 comments on commit d1215e2

Please sign in to comment.