コンテンツにスキップ

WebGPU

WebGPU API ↗を使用すると、JavaScriptから直接GPUを利用できます。

WebGPU APIはDurable Objects内からのみアクセス可能です。Workers内からWebGPU APIを使用することはできません。

ローカル開発でWebGPU APIを使用するには、Durable Objectのwrangler.toml設定ファイルでexperimentalおよびwebgpuの互換性フラグを有効にしてください。

compatibility_flags = ["experimental", "webgpu"]

以下のWebGPU APIのサブセットはDurable Objects内で利用可能です:

APISupported?Notes
navigator.gpu ↗✅
GPU.requestAdapter ↗✅
GPUAdapterInfo ↗✅
GPUAdapter ↗✅
GPUBindGroupLayout ↗✅
GPUBindGroup ↗✅
GPUBuffer ↗✅
GPUCommandBuffer ↗✅
GPUCommandEncoder ↗✅
GPUComputePassEncoder ↗✅
GPUComputePipeline ↗✅
GPUComputePipelineError ↗✅
GPUDevice ↗✅
GPUOutOfMemoryError ↗✅
GPUValidationError ↗✅
GPUInternalError ↗✅
GPUDeviceLostInfo ↗✅
GPUPipelineLayout ↗✅
GPUQuerySet ↗✅
GPUQueue ↗✅
GPUSampler ↗✅
GPUCompilationMessage ↗✅
GPUShaderModule ↗✅
GPUSupportedFeatures ↗✅
GPUSupportedLimits ↗✅
GPUMapMode ↗✅
GPUShaderStage ↗✅
GPUUncapturedErrorEvent ↗✅

以下のWebGPU APIのサブセットはまだサポートされていません:

APISupported?Notes
GPU.getPreferredCanvasFormat ↗
GPURenderBundle ↗
GPURenderBundleEncoder ↗
GPURenderPassEncoder ↗
GPURenderPipeline ↗
GPUShaderModule ↗
GPUTexture ↗
GPUTextureView ↗
GPUExternalTexture ↗

例

  • workers-wonnx ↗ — WebGPU APIを介してGPU上で実行される画像分類、wonnx ↗モデル推論ランタイムを使用。