コンテンツにスキップ

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モデル推論ランタイムを使用。