ポータブル予測サーバー¶
本機能の提供について
ポータブル予測サーバーは、DataRobot MLOps専用のプレミアム機能です。 この機能を有効にする方法については、DataRobotの担当者または管理者にお問い合わせください。
ポータブル予測サーバー(PPS)は、自己完結型のDockerイメージとして配布されるDataRobotモデルパッケージ(.mlpkgファイル)用のDataRobot実行環境です。 ポータブル予測サーバーを設定したら、単一または複数モデルのポータブルリアルタイム予測やポータブルバッチ予測ジョブの実行を開始できます。 ポータブル予測サーバーで実行したいモデルパッケージが時系列モデルの場合、追加設定を行うことができます。
CPUに関する注意事項
DataRobotでは、Intel CPUを使用して、ポータブル予測サーバーを実行することを強く推奨します。 Intel以外のCPUを使用すると、特に、TensorflowまたはKerasで構築されたディープラーニングのようなモデルで、予測の不一致となる場合があります。 これには、ARMアーキテクチャプロセッサー(AArch32やAArch64など)が含まれます。
一般的な設定手順は次のとおりです。
- モデルパッケージのダウンロード
- PPS Dockerイメージをダウンロードします。
- PPS Dockerへのイメージのロード
- DataRobotが提供するDockerスニペットをコピーして、Dockerコンテナでポータブル予測サーバーを実行します。
重要
デプロイによってモデルのポータブル予測サーバーを設定したい場合は、まず外部の予測環境を追加して、そのモデルを外部環境へデプロイする必要があります。
モデルパッケージのダウンロード¶
外部予測環境で実行中のデプロイ済みDataRobotモデルのPPSモデルパッケージをダウンロードすることができます。 さらに、適切なMLOps権限があれば、リーダーボードからモデルパッケージをダウンロードできます。 その後、DataRobotの外でポータブル予測サーバーを使って予測ジョブを実行できます。
デプロイからモデルパッケージをダウンロードすると、ポータブル予測サーバーはモデルのパフォーマンスを監視 して予測統計を追跡します。ただし、デプロイでモデルパッケージのダウンロードがサポートされていることを確認する必要があります。 デプロイには、DataRobotの構築環境と外部予測環境が必要です。これは、デプロイインベントリのガバナンスレンズを使用して確認することができます。
デプロイに外部予測環境がない場合はどうなりますか?
ポータブル予測サーバーで実行したいデプロイ済みモデルが外部の予測環境と関連付けられていない場合、次のいずれかを実行できます。
- 外部予測環境を持つ新しいデプロイを作成します。
- 適切な権限を持っている場合は、リーダーボードからモデルパッケージをダウンロードします。
モデルパッケージのダウンロードをサポートしていないデプロイにアクセスした場合、デプロイからリーダーボードにすばやく移動できます。
- (概要タブで)モデル名をクリックし、モデルレジストリでモデルパッケージを開きます。
- モデルレジストリで、(パッケージ情報タブの)モデル名*をクリックすると、そのモデルがリーダーボードに表示されます。
- リーダーボードで、予測 > ポータブル予測タブからポータブル予測サーバーモデルパッケージをダウンロードします。
リーダーボードからモデルパッケージをダウンロードした場合、ポータブル予測サーバーはモデルのパフォーマンスを監視したり、予測統計を追跡したりすることはありません。
デプロイタブ(デプロイインベントリ)で、DataRobotの構築環境と外部の予測環境の両方を持つデプロイを開き、予測 > ポータブル予測タブに移動します。
| 要素 | 説明 | |
|---|---|---|
| 1 | ポータブル予測サーバー | REST APIベースの予測サーバーをDockerイメージとして設定するのに便利です。 |
| 2 | ポータブル予測サーバーの使用方法 | ポータブル予測サーバーのDockerイメージを取得するAPIのキーとツールタブにリンクします。 |
| 3 | モデルパッケージ(.mlpkg)をダウンロード | デプロイされたモデルのモデルパッケージをダウンロードします。 リーダーボードからモデルパッケージをダウンロードすることもできます。 |
| 4 | Dockerスニペット | モデルパッケージをダウンロードしたら、Dockerスニペットを使用して、モニタリングが有効になっているモデルのポータブル予測サーバーを起動します。 起動する前に、APIキー、ローカルファイル名、パス、[モニタリング]{1}を指定する必要があります。 |
| 5 | クリップボードにコピー | Dockerスニペットをクリップボードにコピーして、コマンドラインに貼り付けられるようにします。 |
予測 > ポータブル予測タブで、モデルパッケージをダウンロードをクリックします。 ダウンロードが完了すると、ダウンロードがダウンロードバーに表示されます。
モデルパッケージをダウンロードしたら、クリップボードにコピーをクリックし、後で使用するためにコードスニペットを保存します。 ダウンロードしたモデルパッケージでポータブル予測サーバーを起動するには、このコードが必要です。
本機能の提供について
リーダーボードからモデルパッケージをダウンロードできるかどうかは、組織のMLOps設定によって異なります。
AutoMLを使用してモデルを構築し、ポータブル予測サーバーで使用するためにそのモデルパッケージをダウンロードする場合は、リーダーボードのモデルに移動し、予測 > ポータブル予測タブを選択します。 時系列モデルのモデルパッケージの場合、予測間隔を計算するかどうかを選択できます。
備考
リーダーボードからダウンロードした場合、ポータブル予測サーバーはモデルのパフォーマンスを監視したり、予測統計を追跡したりすることはありません。
.mlpkgをダウンロードをクリックします。 モデルパッケージをダウンロードしたら、クリップボードにコピーをクリックし、後で使用するためにコードスニペットを保存します。 ダウンロードしたモデルパッケージでポータブル予測サーバーを起動するには、このコードが必要です。
時系列モデルパッケージのダウンロード¶
ポータブル予測で時系列モデルをエクスポートする場合は、モデルパッケージ生成時のモデルの時系列予測間隔(1~100)の計算を有効にすることができます。 このインターフェイスは時系列以外のモデルのインターフェイスと同じですが、予測間隔の計算設定が追加されています。
モデルパッケージ生成のパフォーマンスに関する注意事項
予測区間を計算オプションはデフォルトで無効になっています。これは、予測間隔の計算と組み込みにより、モデルパッケージの生成に要する時間が大幅に増加する可能性があるためです。
モデルパッケージの予測間隔を有効にし、モデルをポータブル予測サーバーにデプロイした後、.yaml PPS設定ファイルまたはPPS環境変数を使用して、予測間隔のパーセンタイルと指数傾向を設定できます。
備考
以下の環境変数は、YAML設定が指定されていない場合にのみ使用されます。
| YAML変数 / 環境変数 | 説明 | タイプ | デフォルト |
|---|---|---|---|
prediction_intervals_percentile / MLOPS_PREDICTION_INTERVALS_PERCENTILE |
予測間隔範囲の定義に使用するパーセンタイルを設定します。 | 整数 | 80 |
ポータブル予測サーバーの設定¶
ダウンロードしたモデルパッケージをポータブル予測サーバーにデプロイするには、まずPPS Dockerイメージをダウンロードし、そのイメージをDockerに読み込む必要があります。
PPS Dockerイメージの取得¶
APIのキーとツールタブに移動して、ポータブル予測サーバーのDockerイメージをダウンロードします。 次の表で説明するように、DataRobotの環境とバージョンに応じて最新のイメージにアクセスするためのオプションが異なる場合があります。
| デプロイのタイプ | ソフトウェアバージョン | アクセス方法 |
|---|---|---|
| セルフマネージドAIプラットフォーム | v6.3以前 | 詳細については、DataRobotの担当者に連絡してください。 イメージはリクエストに応じて提供されます。 |
| セルフマネージドAIプラットフォーム | v7.0以降 | APIのキーとツールからイメージをダウンロードし、以下の説明に従ってインストールします。 イメージを取得できない場合は、DataRobotの担当者に連絡してください。 |
| マネージドAIプラットフォーム | 2021年1月以降 | APIのキーとツールからイメージをダウンロードし、以下の説明に従ってインストールします。 |
Dockerへのイメージのロード¶
注意
現在、DataRobotはイメージサイズの縮小に取り組んでいますが、圧縮されたDockerイメージは6 GBを超える場合があります(Dockerが読み込まれたイメージのレイヤーは14 GBを超える場合があります)。 PPSイメージをダウンロードおよびインポートする場合は、これらのサイズを考慮してください。
続行する前に、開発者ツールからイメージをダウンロードします。 Dockerで読み込める、gzipされたtarアーカイブです。
ダウンロードしてファイルのチェックサムを確認したら、docker loadを使用してイメージを読み込みます。 Dockerはgzipされたtarアーカイブからのイメージ読み込みをネイティブにサポートしているので、ダウンロードしたファイルを解凍する必要はありません。
以下のコマンドをコピーし、<version>を置き換えてコマンドを実行すると、PPSイメージがDockerに読み込まれます。
docker load < datarobot-portable-prediction-api-<version>.tar.gz
備考
PPSファイルがカレントディレクトリにない場合は、tarファイルへのローカルな絶対ファイルパスを指定する必要があります(例:/path/to/datarobot-portable-prediction-api-<version>.tar.gz)。
PPSファイルにdocker loadコマンドを実行すると、次のような出力が表示されるはずです。
docker load < datarobot-portable-prediction-api-9.0.0-r4582.tar.gz
33204bfe17ee: Loading layer [==================================================>] 214.1MB/214.1MB
62c077c42637: Loading layer [==================================================>] 3.584kB/3.584kB
54475c7b6aee: Loading layer [==================================================>] 30.21kB/30.21kB
0f91625c248c: Loading layer [==================================================>] 3.072kB/3.072kB
21c5127d921b: Loading layer [==================================================>] 27.05MB/27.05MB
91feb2d07e73: Loading layer [==================================================>] 421.4kB/421.4kB
12ca493d22d9: Loading layer [==================================================>] 41.61MB/41.61MB
ffb6e915efe7: Loading layer [==================================================>] 26.55MB/26.55MB
83e2c4ee6761: Loading layer [==================================================>] 5.632kB/5.632kB
109bf21d51e0: Loading layer [==================================================>] 3.093MB/3.093MB
d5ebeca35cd2: Loading layer [==================================================>] 646.6MB/646.6MB
f72ea73370ce: Loading layer [==================================================>] 1.108GB/1.108GB
4ecb5fe1d7c7: Loading layer [==================================================>] 1.844GB/1.844GB
d5d87d53ea21: Loading layer [==================================================>] 71.79MB/71.79MB
34e5df35e3cf: Loading layer [==================================================>] 187.3MB/187.3MB
38ccf3dd09eb: Loading layer [==================================================>] 995.5MB/995.5MB
fc5583d56a81: Loading layer [==================================================>] 3.584kB/3.584kB
c51face886fc: Loading layer [==================================================>] 402MB/402MB
c6017c1b6604: Loading layer [==================================================>] 1.465GB/1.465GB
7a879d3cd431: Loading layer [==================================================>] 166.6MB/166.6MB
8c2f17f7a166: Loading layer [==================================================>] 188.7MB/188.7MB
059189864c15: Loading layer [==================================================>] 115.9MB/115.9MB
991f5ac99c29: Loading layer [==================================================>] 3.072kB/3.072kB
f6bbaa29a1c6: Loading layer [==================================================>] 2.56kB/2.56kB
4a0a241b3aab: Loading layer [==================================================>] 415.7kB/415.7kB
3d509cf1aa18: Loading layer [==================================================>] 5.632kB/5.632kB
a611f162b44f: Loading layer [==================================================>] 1.701MB/1.701MB
0135aa7d76a0: Loading layer [==================================================>] 6.766MB/6.766MB
fe5890c6ddfc: Loading layer [==================================================>] 4.096kB/4.096kB
d2f4df5f0344: Loading layer [==================================================>] 5.875GB/5.875GB
1a1a6aa8556e: Loading layer [==================================================>] 10.24kB/10.24kB
77fcb6e243d1: Loading layer [==================================================>] 12.97MB/12.97MB
7749d3ff03bb: Loading layer [==================================================>] 4.096kB/4.096kB
29de05e7fdb3: Loading layer [==================================================>] 3.072kB/3.072kB
2579aba98176: Loading layer [==================================================>] 4.698MB/4.698MB
5f3d150f5680: Loading layer [==================================================>] 4.699MB/4.699MB
1f63989f2175: Loading layer [==================================================>] 3.798GB/3.798GB
3e722f5814f1: Loading layer [==================================================>] 182.3kB/182.3kB
b248981a0c7e: Loading layer [==================================================>] 3.072kB/3.072kB
b104fa769b35: Loading layer [==================================================>] 4.096kB/4.096kB
Loaded image: datarobot/datarobot-portable-prediction-api:9.0.0-r4582
docker loadコマンドがLoaded imageメッセージとともに正常に完了したら、イメージがdocker imagesコマンドで読み込まれていることを確認する必要があります。
以下のコマンドをコピーして実行すると、Dockerにあるイメージの一覧が表示されます。
docker images
この例では、前の手順で読み込んだ datarobot/datarobot-portable-prediction-apiイメージを確認できます。
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
datarobot/datarobot-portable-prediction-api 9.0.0-r4582 df38ea008767 29 hours ago 17GB
ヒント
(オプション)圧縮されたイメージアーカイブdatarobot-portable-prediction-api-<version>.tar.gzは、正常に読み込めたら削除することで、ディスクスペースを節約できます(オプション)。
コードスニペットでのPPSの起動¶
モデルパッケージをダウンロードしてDocker PPSイメージを設定したら、関連するdocker runコードスニペットを使用して、ダウンロードしたモデルパッケージでポータブル予測サーバーを起動することができます。
OpenShiftでのPPSの起動
OpenShift環境でPPSを実行する場合、NGINXがデフォルトで特権ポートの使用を試行しないようにするには、OpenShiftにデプロイされたYAMLに以下の環境変数設定を含める必要があります。
env:
- name: NGINX_BIND_PRIVILEGES_MODE
value: "unprivileged"
デプロイされたモデルからのこちらのコードスニペット例では、以下にハイライトされたオプションを設定する必要があります。
1 2 3 4 5 6 7 8 9 10 | |
-
-v <local path to model package>/:/opt/ml/model/ \: ダウンロードしたモデルパッケージの場所へのローカルな絶対ファイルパスを指定します。-v(または--volume)オプションのバインドでボリュームをマウントし、(<local path to model package>の)ローカルモデルパッケージディレクトリの内容をDockerコンテナの/opt/ml/modelボリュームに追加します。 -
-e PREDICTION_API_MODEL_REPOSITORY_PATH="/opt/ml/model/<model package file name>" \:/opt/ml/model/ボリュームにマウントされたモデルパッケージのファイル名を指定します。 これにより、PPSがモデルパッケージを見つけられる場所を示す環境変数PREDICTION_API_MODEL_REPOSITORY_PATHが設定されます。 -
-e MONITORING_AGENT_DATAROBOT_APP_TOKEN="<your api token>" \: 監視目的で、DataRobotの開発者ツールからAPIトークンを提供します。 これにより、環境変数MONITORING_AGENT_DATAROBOT_APP_TOKENが設定され、PPSがAPIキーを見つけられるようになります。 -
datarobot-portable-prediction-api:この行を、使用しているPPSイメージのイメージ名とバージョンで置き換えます。 例:datarobot/datarobot-portable-prediction-api:<version>。
リーダーボードモデル向けのこちらのコードスニペット例では、以下にハイライトされたオプションを設定する必要があります。
1 2 3 4 5 | |
-
-v <local path to model package>/:/opt/ml/model/ \: ダウンロードしたモデルパッケージがあるディレクトリへのローカルな絶対ファイルパスを指定します。-v(または--volume)オプションのバインドでボリュームをマウントし、(<local path to model package>の)ローカルモデルパッケージディレクトリの内容をDockerコンテナの/opt/ml/modelボリュームに追加します。 -
-e PREDICTION_API_MODEL_REPOSITORY_PATH="/opt/ml/model/<model package file name>" \:/opt/ml/model/ボリュームにマウントされたモデルパッケージのファイル名を指定します。 これにより、PPSがモデルパッケージを見つけられる場所を示す環境変数PREDICTION_API_MODEL_REPOSITORY_PATHが設定されます。 -
datarobot-portable-prediction-api:この行を、使用しているPPSイメージのイメージ名とバージョンで置き換えます。 例:datarobot/datarobot-portable-prediction-api:<version>。
dockerタグを使用してイメージに名前とタグを付ける
あるいは、docker tagを使用して新しいイメージにlatestというタグを付けてdatarobot-portable-prediction-apiに名前を変更すれば、最後の行にdatarobot-portable-prediction-apiを残すことができます。
この例では、Dockerはイメージの名前を変更し、9.0.0-r4582タグをlatestタグで置き換えています。
docker tag datarobot/datarobot-portable-prediction-api:9.0.0-r4582 datarobot-portable-prediction-api:latest
新しいタグと名前を確認するには、もう一度docker imagesコマンドを使用します。
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
datarobot/datarobot-portable-prediction-api 9.0.0-r4582 df38ea008767 29 hours ago 17GB
datarobot-portable-prediction-api latest df38ea008767 29 hours ago 17GB
セットアップを完了したら、Dockerスニペットを使用して、単一または複数モデルのポータブルリアルタイム予測の実行や、ポータブルバッチ予測の実行ができます。 PPSを使用した予測ジョブの追加の例も参照してください。 PPSは、メインのDataRobotインストール環境から切り離して実行することができます。 開始すると、イメージは:8080ポートを介してHTTP APIを提供します。
FIPS対応モデルパッケージのPPSを実行する
A DataRobot cluster that's configured for FIPS records its FIPS mode in every .mlpkg file that it builds. A cluster is configured for FIPS when ENABLE_FIPS_140_2_MODE: true or ENABLE_FIPS_140_3_MODE: true is set in core.config_env_vars in the DataRobot Helm values.
Launch the PPS with the same FIPS settings as the cluster that built the model package. For a model package from a FIPS cluster, set ENABLE_FIPS_140_2_MODE or ENABLE_FIPS_140_3_MODE to the same value as the cluster. For a model package from a standard cluster, leave both variables unset.
The FIPS settings select the hash algorithm that the PPS uses for model identifiers: MD5 for a standard cluster, SHA-1 for FIPS 140-2, and SHA-256 for FIPS 140-3. Before the PPS loads a model package, it checks that the model package uses the same hash algorithm. If it doesn't, the PPS doesn't load the model package, and a prediction request returns HTTP 422 with a Model package digest mismatch error. The error names the setting to launch the PPS with. Because a PPS instance uses one hash algorithm, a single PPS instance can't host model packages that use different hash algorithms.
PPS images from before Release 11.15 also require the FIPS settings to match the model package exactly. Otherwise, they return a misconfigured attributes 'FIPS 140-2 mode' or misconfigured attributes 'FIPS 140-3 mode' error.
FIPS 140-3 model packages require a PPS image from Release 11.12 or later. Earlier PPS images don't check for FIPS 140-3 mode and don't use SHA-256, so the model in a FIPS 140-3 model package fails to load. A prediction request returns HTTP 500 with a Vertex is not stored error. To serve the model package, update the PPS image tag.
The docker run code snippet for the deployment already includes the FIPS arguments that the model package needs, including SAFE_HASH_LEGACY_ALGORITHM when the model package needs it. Don't add them to the copied command. If a warning above the snippet says that the model package's details couldn't be loaded, reload the page before you copy the command, because the command can be missing these arguments.
To write your own docker run command, add the FIPS arguments yourself. For a model package from a FIPS 140-2 cluster:
-e ENABLE_FIPS_140_2_MODE="true"
For a model package from a FIPS 140-3 cluster:
-e ENABLE_FIPS_140_3_MODE="true"
-e DATAROBOT_FIPS_ENFORCE="true"
ENABLE_FIPS_140_3_MODE only selects the hash algorithm. Without DATAROBOT_FIPS_ENFORCE, the PPS doesn't load its FIPS-enforcing OpenSSL configuration. DATAROBOT_FIPS_ENFORCE requires a PPS image from Release 11.15 or later. Earlier images ignore it, so they run without the FIPS-enforcing OpenSSL configuration.
For example, the full command for a model package from a FIPS 140-3 cluster looks like the following:
docker run \
-td \
-p 8080:8080 \
-e PYTHON3_SERVICES="true" \
-e ENABLE_FIPS_140_3_MODE="true" \
-e DATAROBOT_FIPS_ENFORCE="true" \
-v <local path to model package>/:/opt/ml/model \
--name portable_predictions_server \
--rm datarobot/datarobot-portable-prediction-api:<version>
For a model package from a FIPS 140-2 cluster, replace the ENABLE_FIPS_140_3_MODE and DATAROBOT_FIPS_ENFORCE lines with -e ENABLE_FIPS_140_2_MODE="true".
Clusters upgraded to FIPS 140-3
A cluster upgraded to FIPS 140-3 can set SAFE_HASH_LEGACY_ALGORITHM to keep the model identifiers that the cluster used before the upgrade. Set SAFE_HASH_LEGACY_ALGORITHM to md5 for a cluster upgraded from a standard installation, or to sha1 for a cluster upgraded from FIPS 140-2.
A model package from such a cluster records its hash algorithm, and the docker run code snippet for the deployment adds SAFE_HASH_LEGACY_ALGORITHM with the value that the model package needs. In your own command, launch the PPS with the same value as the cluster. To find the value that the cluster uses, ask your DataRobot administrator, or check the error that the PPS returns when the values don't match. For an explanation of the two values, see Choose the legacy hash algorithm.
In the following command, replace <legacyAlgorithm> with md5 or sha1:
-e SAFE_HASH_LEGACY_ALGORITHM="<legacyAlgorithm>"
備考:
- If the value doesn't match, the PPS doesn't load the model package. A prediction request returns HTTP 422 with an error that names the hash algorithm that the model package uses and the setting to launch the PPS with, for example
Start the container with SAFE_HASH_LEGACY_ALGORITHM=md5 to serve it. - Use a PPS image from Release 11.15 or later. Earlier images ignore this setting, so they don't serve the model package. A prediction request returns HTTP 422 with a
misconfigured attributes 'FIPS 140-3 mode'error, or HTTP 500 with aVertex is not storederror when the model fails to load. If you see either error, update the PPS image tag. - A PPS launched with the settings of the upgraded cluster also loads the model packages that the cluster built before the upgrade, because they use the same hash algorithm.
Model packages that don't record their hash algorithm
FIPS 140-2 clusters have used SHA-1 identifiers since 2021-06-15, but model packages have recorded whether the cluster ran FIPS 140-2 only since 2023-05-03. A model package exported between those dates, or with no export date, that records neither its hash algorithm nor a FIPS setting can therefore use either MD5 or SHA-1. The docker run code snippet for the deployment can't tell which, so it doesn't include SAFE_HASH_LEGACY_ALGORITHM for these model packages.
Launch the PPS with SAFE_HASH_LEGACY_ALGORITHM=sha1 if the cluster that exported the model package ran FIPS 140-2, and with SAFE_HASH_LEGACY_ALGORITHM=md5 otherwise. If the PPS uses another hash algorithm, it doesn't load the model package. A prediction request then returns HTTP 422 with a digest-mismatch error that names both settings and both dates. If the PPS accepts the model package but the model fails to load (HTTP 500), use the other value. A model package exported before 2021-06-15 always uses MD5, and the error names SAFE_HASH_LEGACY_ALGORITHM=md5.






