Skip to content

Latest commit

 

History

History
124 lines (88 loc) · 3.63 KB

File metadata and controls

124 lines (88 loc) · 3.63 KB

Build OpenVINO™ GenAI Node.js bindings

  1. Build and install OpenVINO from sources following the instructions. In this step, we need to build the OpenVINO Runtime that is required for OpenVINO GenAI. We don't need to configure any environment variables to create JS buildings here. The path to the OpenVINO install directory is referred as <INSTALL_DIR> throughout the document.

  2. Clone OpenVINO GenAI repository and init submodules:

    git clone --recursive https://github.com/openvinotoolkit/openvino.genai.git
    cd openvino.genai
  3. Set up the environment:

    Option 1 - using OpenVINO setupvars script:

    Linux and macOS:

    source <INSTALL_DIR>/setupvars.sh

    Windows Command Prompt:

    call <INSTALL_DIR>\setupvars.bat

    Windows PowerShell:

    . <INSTALL_DIR>/setupvars.ps1

    Option 2 - setting environment variables manually:

    Linux:

    export OpenVINO_DIR=<INSTALL_DIR>/runtime
    export PYTHONPATH=<INSTALL_DIR>/python:./build/:$PYTHONPATH
    export LD_LIBRARY_PATH=<INSTALL_DIR>/runtime/lib/intel64:$LD_LIBRARY_PATH

    macOS:

    export OpenVINO_DIR=<INSTALL_DIR>/runtime
    export PYTHONPATH=<INSTALL_DIR>/python:./build/:$PYTHONPATH
    export DYLD_LIBRARY_PATH=<INSTALL_DIR>/runtime/lib/intel64:$LD_LIBRARY_PATH

    Windows Command Prompt:

    set OpenVINO_DIR=<INSTALL_DIR>\runtime
    set PYTHONPATH=<INSTALL_DIR>\python;%CD%\build;%PYTHONPATH%
    set OPENVINO_LIB_PATHS=<INSTALL_DIR>\bin\intel64\Release;%OPENVINO_LIB_PATHS%
    set PATH=%OPENVINO_LIB_PATHS%;%PATH%

    Windows PowerShell:

    $env:OpenVINO_DIR = "<INSTALL_DIR>\runtime"
    $env:PYTHONPATH = "<INSTALL_DIR>\python;$PWD\build;$env:PYTHONPATH"
    $env:OPENVINO_LIB_PATHS = "<INSTALL_DIR>\bin\intel64\Release;$env:OPENVINO_LIB_PATHS"
    $env:PATH = "$env:OPENVINO_LIB_PATHS;$env:PATH"
  4. Build OpenVINO GenAI Node.js bindings

    cmake -DCMAKE_BUILD_TYPE=Release \
        -DENABLE_JS=ON -DCPACK_GENERATOR=NPM \
        -S . -B ./build
    cmake --build ./build --config Release -j
    cmake --install ./build/ --config Release --prefix ./src/js/bin

Install and Run

Requirements

  • Node.js v21+

Build Bindings

Build OpenVINO™ GenAI JavaScript Bindings from sources following the instructions.

Using the package from your project

Since the OpenVINO GenAI NodeJS package depends on the OpenVINO NodeJS package, these packages must be of the same version. If you intend to use one of the released versions, please check and install the correct version of the openvino-node package in your project. If you want to use an unstable version of the OpenVINO GenAI NodeJS package, you will also need to build and use OpenVINO™ JavaScript Bindings from source following the instructions to use it correctly.

Then you can use OpenVINO™ GenAI JavaScript Bindings in one of the following ways:

Option 1 - using npm:

To use this package locally use npm link in src/js/ directory and npm link openvino-genai-node in the folder where you want to add this package as a dependency

Option 2 - using package.json:

Add the openvino-genai-node package manually by specifying the path to the src/js/ directory in your package.json:

"openvino-genai-node": "file:*path-to-current-directory*"

Verify the installation:

node -e "const { LLMPipeline } = require('openvino-genai-node'); console.log(LLMPipeline);"