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/ 進行使用。