Skip to main content

WebGPU Execution Provider

The WebGPU Execution Provider enables GPU-accelerated inference in web browsers using the WebGPU API, providing high-performance machine learning inference directly in the browser.

When to Use WebGPU EP

Use the WebGPU Execution Provider when:
  • You’re building web applications with ML inference
  • You need GPU acceleration in the browser
  • You want better performance than WebAssembly CPU execution
  • Your users have modern browsers with WebGPU support
  • You’re deploying client-side ML applications
  • You want to reduce server costs by running inference on client devices

Key Features

  • GPU Acceleration: Leverage user’s GPU for fast inference
  • Cross-Platform: Works on Windows, macOS, Linux, ChromeOS
  • Modern API: Based on next-generation graphics API
  • Better Performance: 5-10x faster than WebAssembly CPU
  • Privacy-Friendly: Inference runs locally, no data sent to server
  • Progressive Enhancement: Fallback to CPU when GPU unavailable

Prerequisites

Browser Support

WebGPU is supported in: Desktop:
  • Chrome/Edge 113+ (Windows, macOS, Linux, ChromeOS)
  • Safari 18+ (macOS)
  • Firefox (experimental, enable via flag)
Mobile:
  • Chrome Android 113+ (limited support)
  • Safari iOS 18+ (limited support)

Checking Browser Support

Development Environment

  • Node.js: 16+ (for building)
  • ONNX Runtime Web: Latest version
  • Modern bundler: Webpack, Vite, or Rollup

Installation

NPM Package

CDN (Development)

Building Your App

Basic Usage

JavaScript/TypeScript

With Fallback

React Example

Configuration Options

Session Options

WebGPU-Specific Options

Environment Configuration

Performance Optimization

Model Loading

Batch Processing

Warm-up

Tensor Management

Deployment

Webpack Configuration

Vite Configuration

Service Worker

Common Use Cases

Image Classification

Object Detection

Real-Time Video Processing

Browser Compatibility

Troubleshooting

WebGPU Not Available

CORS Issues

Performance Monitoring

Memory Issues

Performance Comparison

Typical performance on modern laptop (relative to CPU):

Next Steps