使用 ONNX Runtime Node.js 绑定入门

目录

安装

# install latest release version
npm install onnxruntime-node

导入

// use ES6 style import syntax (recommended)
import * as ort from 'onnxruntime-node';
// or use CommonJS style import syntax
const ort = require('onnxruntime-node');

示例

  • 请遵循 ONNX Runtime Node.js 绑定的快速入门说明。

支持的版本

下表列出了 ONNX Runtime Node.js 绑定预构建二进制文件所支持的版本。

EP/平台 Windows x64 Windows arm64 Linux x64 Linux arm64 MacOS x64 MacOS arm64
CPU ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
DirectML ✔️ ✔️
CUDA ✔️[1]
  • [1]: CUDA v11.8。

对于不在列表中的平台或需要自定义构建,您可以从源代码构建 Node.js 绑定,然后使用 npm install <onnxruntime_repo_root>/js/node/ 进行使用。