Movatterモバイル変換


[0]ホーム

URL:


Skip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied

Get started with ONNX Runtime Web

Contents

Install

Use the following command in shell to install ONNX Runtime Web:

# install latest release versionnpminstallonnxruntime-web# install nightly build dev versionnpminstallonnxruntime-web@dev

Import

Use the following JavaScript code to import ONNX Runtime Web:

// use ES6 style import syntax (recommended)import*asortfrom'onnxruntime-web';
// or use CommonJS style import syntaxconstort=require('onnxruntime-web');

If you want to use ONNX Runtime Web with WebGPU support (experimental feature), you need to import as below:

// use ES6 style import syntax (recommended)import*asortfrom'onnxruntime-web/webgpu';
// or use CommonJS style import syntaxconstort=require('onnxruntime-web/webgpu');

If you want to use ONNX Runtime Web with WebNN support (experimental feature), you need to import as below:

// use ES6 style import syntax (recommended)import*asortfrom'onnxruntime-web/experimental';
// or use CommonJS style import syntaxconstort=require('onnxruntime-web/experimental');

For a complete table for importing, seeConditional Importing.

Documentation

SeeONNX Runtime JavaScript API for API reference. Please also check the following links for API usage examples:

SeeTutorial: Web for tutorials.

SeeTraining on web demo for training using onnxruntime-web.

Examples

The following examples describe how to use ONNX Runtime Web in your web applications for model inferencing:

The following are E2E examples that uses ONNX Runtime Web in web applications:

The following are video tutorials that use ONNX Runtime Web in web applications:

Supported Versions

EPs/BrowsersChrome/Edge (Windows)Chrome/Edge (Android)Chrome/Edge (macOS)Chrome/Edge (iOS)Safari (macOS)Safari (iOS)Firefox (Windows)Node.js
WebAssembly (CPU)✔️✔️✔️✔️✔️✔️✔️✔️[1]
WebGPU✔️[2]✔️[3]✔️
WebGL✔️[4]✔️[4]✔️[4]✔️[4]✔️[4]✔️[4]✔️[4]
WebNN✔️[5]
  • [1]: Node.js only support single-threadedwasm EP.
  • [2]: WebGPU requires Chromium v113 or later on Windows. Float16 support requires Chrome v121 or later, and Edge v122 or later.
  • [3]: WebGPU requires Chromium v121 or later on Windows.
  • [4]: WebGL support is in maintenance mode. It is recommended to use WebGPU for better performance.
  • [5]: Requires to launch browser with commandline flag--enable-features=WebMachineLearningNeuralNetwork.


[8]ページ先頭

©2009-2025 Movatter.jp