コンテンツにスキップ

ソースからビルド

generate() APIをソースからビルドする

Section titled “generate() APIをソースからビルドする”
  • cmake
  • .NET6 (C#をビルドする場合)

onnxruntime-genaiリポジトリをクローンする

Section titled “onnxruntime-genaiリポジトリをクローンする”
Terminal window
git clone https://github.com/microsoft/onnxruntime-genai
cd onnxruntime-genai

このステップは、onnxruntime-genaiリポジトリのルートにいることを前提としています。

以下のすべてのビルドコマンドには--config引数があり、次のオプションを取ります。

  • Release リリースバイナリをビルドします
  • Debug デバッグシンボル付きのバイナリをビルドします
  • RelWithDebInfo デバッグ情報付きのリリースバイナリをビルドします
Terminal window
python build.py --config Release
Terminal window
python build.py --use_dml --config Release
Terminal window
python build.py --use_trt_rtx --config Release --cuda_home <cuda_path>
Terminal window
python build.py --config Release
Terminal window
python build.py --use_cuda --config Release
Terminal window
python build.py --config Release
Terminal window
python build.py --build_java --config Release

Windowsでビルドする場合は、ninjaをインストールします。

Terminal window
pip install ninja

ビルドスクリプトを実行します。

Terminal window
python build.py --build_java --android --android_home <Android SDKへのパス> --android_ndk_path <NDKインストールへのパス> --android_abi [armeabi-v7a|arm64-v8a|x86|x86_64] --config Release

アプリケーションにライブラリをインストールする

Section titled “アプリケーションにライブラリをインストールする”

Pythonホイールをインストールする

Section titled “Pythonホイールをインストールする”
Terminal window
# onnxruntime-genaiホイールを含むフォルダにディレクトリを変更します
# Linuxの例:cd build/Linux/Release/wheel/
pip install *.whl

近日公開

build/Windows/Release/src/java/build/libs/*.jarをアプリケーションにコピーします。

build/Android/Release/src/java/build/android/outputs/aar/onnxruntime-genai-release.aarをアプリケーションにコピーします。

C/C++ヘッダーファイルとライブラリをインストールする

Section titled “C/C++ヘッダーファイルとライブラリをインストールする”

src\ort_genai.hのヘッダーとbuild\Windows\Releaseのライブラリを使用します。

src/ort_genai.hのヘッダーとbuild/Linux/Releaseのライブラリを使用します。