Skip to content

[V4] pipeline.dispose() destroys WebGPU device, can't be recreated afterwards #1576

@nico-martin

Description

@nico-martin

System Info

Browser and all environments that support WebGPU.

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

Due to a bug in onnxruntime, after we dispose a pipeline or a model the WebGPU is destroyed, but the JavaScript reference in env.webgpu.device is never cleared, leaving a stale reference to a destroyed device.

This means next time it tries create a WebGOU session, it tries to access the destroyed WebGPU device and fails.

Reproduction

  1. install Transformers.js v4 npm i @huggingface/transformers@next

  2. create a pipeline with webgpu:

const pipe = await pipeline(
  "feature-extraction",
  "onnx-community/all-MiniLM-L6-v2-ONNX",
  {
    device: "webgpu",
  }
);
  1. destroy the pipeline
pipe.dispose();
  1. create a new pipeline with webgpu:
const pipe2 = await pipeline(
  "feature-extraction",
  "onnx-community/all-MiniLM-L6-v2-ONNX",
  {
    device: "webgpu",
  }
);

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions