Skip to main content
The WebGPU execution provider enables GPU-accelerated inference directly in web browsers using the modern WebGPU API, providing cross-platform GPU access without plugins or native installations.

Requirements

Browser Support

  • Chrome/Edge: Version 113+ (stable support)
  • Firefox: Version 121+ (experimental, requires flag)
  • Safari: Version 18+ (Technology Preview)
  • Opera: Version 99+

Hardware

  • GPU with Vulkan, Metal, or DirectX 12 support
  • Supported GPUs:
    • NVIDIA (Vulkan/DirectX 12)
    • AMD (Vulkan/DirectX 12)
    • Intel (Vulkan/DirectX 12)
    • Apple Silicon (Metal)
WebGPU is still evolving. Check caniuse.com/webgpu for current browser support.

Installation

Basic Configuration

JavaScript API

TypeScript

Memory Management

GPU Buffer Management

WebGPU uses GPU buffers for efficient memory management:
WebGPU buffer handles cannot use pointer arithmetic. Full-buffer copies are used for operations requiring offsets.

Memory Transfer Optimization

Configuration Options

Session Options

INT64 Support

WebGPU requires explicit INT64 enablement:

Browser Compatibility

Feature Detection

Progressive Enhancement

Performance Optimization

Model Optimization

Batch Processing

Precision Control

  • Full precision
  • Best accuracy
  • Higher memory usage
  • Broader browser support

Advanced Usage

Web Worker Integration

Streaming Inference

Troubleshooting

WebGPU Not Available

Memory Errors

Performance Issues

Benchmarking

Best Practices

Feature Detection

Always check for WebGPU support before using it.

Fallback Strategy

Implement fallback to WebAssembly for unsupported browsers.

Model Optimization

Use optimized .ort format and FP16 precision when supported.

Web Workers

Run inference in Web Workers to avoid blocking the main thread.

Next Steps

Web Deployment

Deploy models to the web

Model Optimization

Optimize models for browser inference