| name | burn-wgpu |
| description | Burn WGPU backend - Cross-platform GPU acceleration using WebGPU. Supports Vulkan, Metal, Direct3D, and WebGL. |
burn-wgpu
Overview
burn-wgpu provides cross-platform GPU acceleration using WebGPU through the wgpu crate. It supports:
- Vulkan: Linux, Android
- Metal: macOS, iOS
- Direct3D 12: Windows
- WebGL: Web browsers
Key Features
- Cross-platform GPU: Works on all major platforms
- Web Support: Runs in browsers via WASM
- Automatic Shader Generation: No manual shader writing
- Memory Efficient: Smart memory management
Usage
Basic Setup
use burn::tensor::Tensor;
use burn_wgpu::WgpuDevice;
let device = WgpuDevice::default();
let tensor = Tensor::from_data(&[1.0, 2.0, 3.0], &device);
let result = tensor.matmul(other_tensor);
Backend Type
use burn_wgpu::WgpuBackend;
type Backend = WgpuBackend;
let model: Model<Backend> = Model::default();
burn.toml Configuration
[model_exports]
default_backend = "wgpu"
default_device = "Gpu"
[wgpu]
Best Practices
- Use for production GPU inference
- Enable
wgpu feature for WebAssembly
- Profile memory usage for large models
- Use async operations for better performance
Performance Considerations
- Significantly faster than CPU for large tensors
- Memory transfer overhead between CPU/GPU
- Best for batch processing and large models
- WebAssembly performance may vary by browser
When to Use
- Production GPU inference
- Cross-platform applications
- Web-based ML applications
- High-performance training
Related Crates
burn: Core framework
burn-onnx: ONNX model import with GPU acceleration