

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# モデルをデプロイする
<a name="bedrock-marketplace-deploy-a-model"></a>

モデルをサブスクライブしたら、SageMaker AI エンドポイントにデプロイします。エンドポイントに対して推論コールを実行します。モデルは SageMaker AI によってホストされます。デプロイプロセス中に、以下の情報を提供します。
+ SageMaker AI エンドポイントの名前
+ エンドポイントへの推論コールを実行するインスタンスの数
+ エンドポイントのインスタンスタイプ

必要に応じて、タグなどの詳細オプションを設定することもできます。

SageMaker AI がユーザーに代わってアクションを実行できるように、SageMaker AI サービスロールが自動的に作成されます。Amazon SageMaker AI のアクセス許可の詳細については、「[SageMaker AI 実行ロールの使用方法](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html )」を参照してください。

既存のロールを選択することも、新しいロールを作成することもできます。Amazon Bedrock Marketplace モデルをデプロイする方法については、選択した方法に対応するタブをクリックして、手順に従ってください。

**モデルをデプロイするには**

1. Amazon Bedrock アクセス許可を持つ IAM ロール AWS マネジメントコンソール を使用して にサインインします。

1. 検索バーで「Amazon Bedrock」を指定し、ドロップダウンリストから **Amazon Bedrock** を選択します。

1. ナビゲーションペインから、**[モデルカタログ]** を選択します。

1. デプロイするモデルのモデルカードを選択します。

1. **[デプロイ]** をクリックします。

1. **[エンドポイント名]** には、エンドポイントの名前を入力します。

1. インスタンスの数とインスタンスタイプを選択します。

1. **[詳細設定]** では、オプションで以下を実行できます。

   1. VPC を設定する。

   1. サービスアクセスロールを設定する。

   1. 暗号化設定をカスタマイズする。

   1. タグを追加する。

1. **[デプロイ]** をクリックして、Amazon Bedrock Marketplace モデルを SageMaker AI エンドポイントにデプロイします。このプロセスは通常、10～15 分かかります。

エンドポイントを作成するには、`CreateMarketplaceModelEndpoint` 操作を使用します。モデルによっては、エンドユーザーライセンス契約 (EULA) があります。EULA に同意するには、`AcceptEula` を `True` に設定します。

次の例では、 AWS Command Line Interface コマンドの例を使用してエンドポイントを作成します。

```
aws bedrock create-marketplace-model-endpoint --model-source-identifier {{HubContentArn}} --endpoint-config "{\"sageMaker\":{\"initialInstanceCount\":{{1}},\"instanceType\":\"{{ml.g5.xlarge}}\",\"executionRole\":\"arn:aws:iam::{{111122223333}}:role/{{example-IAM-role}}\"}}" --endpoint-name "{{example-endpoint-name}}"
```

**注記**  
`CreateMarketplaceModelEndpoint` 操作、`UpdateMarketplaceModelEndpoint` 操作、`RegisterMarketplaceModelEndpoint` 操作のレスポンスは同じです。

```
{"marketplaceModelEndpoint":{"createdAt":"2024-11-12T02:31:58.201474085Z","endpoint":{"sageMaker":{"executionRole":"arn:aws:iam::{{111122223333}}:role/service-role/{{amazon-sagemaker-execution-role}}","initialInstanceCount":1,"instanceType":"ml.g5.2xlarge","kmsEncryptionKey":null,"vpc":null}},"endpointArn":"arn:aws:sagemaker:region:{{555555555555}}:endpoint/{{example-endpoint-name}}","endpointStatus":"Creating","endpointStatusMessage":"","modelSourceIdentifier":"arn:aws:sagemaker:region:aws:hub-content/SageMakerPublicHub/Model/{{example-model-name}}/1.2.2","status":"ACTIVE","statusMessage":"","updatedAt":"2024-11-12T02:31:58.201474085Z"}}
```

Amazon Bedrock Marketplace と Amazon SageMaker AI の両方でエンドポイントを変更できます。エンドポイントの変更を行うのは Amazon Bedrock 内のみとすることをお勧めします。SageMaker AI 内でエンドポイントを変更すると、Amazon Bedrock 内でエンドポイントを使用できなくなる可能性があります。Amazon Bedrock 内でのエンドポイントが失敗する原因となる可能性のある変更は次のとおりです。
+ [EnableNetworkIsolation](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html#sagemaker-CreateModel-request-EnableNetworkIsolation) を `False` に設定する。
+ [PrimaryContainer](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html#sagemaker-CreateModel-request-PrimaryContainer) オブジェクト内のモデル定義を変更する。

エンドポイントが動作するには、エンドポイントが登録済みで実行している必要があります。次の AWS Command Line Interface コマンドを使用して、エンドポイントのステータスを確認できます。

```
aws bedrock get-marketplace-model-endpoint --endpoint-arn arn:aws:sagemaker:region:{{111122223333}}:endpoint/{{example-endpoint-name}}            
```

Amazon Bedrock でエンドポイントを使用するには、エンドポイントが以下のステータスである必要があります。

```
endpointStatus: InService
status: REGISTERED
```

エンドポイントの失敗につながる変更を行った場合は、エンドポイントの登録を解除して再登録できます。エンドポイントの登録を解除するには、`DeregisterEndpoint` 操作を使用します。エンドポイントを再登録するには、`RegisterEndpoint` 操作を使用します。

```
aws bedrock deregister-marketplace-model-endpoint --endpoint-arn arn:aws:sagemaker:region:{{111122223333}}:endpoint/{{example-endpoint-name}}
```

```
aws bedrock register-marketplace-model-endpoint --endpoint-identifier arn:aws:sagemaker:region:{{111122223333}}:endpoint/{{example-endpoint-name}} --model-source-identifier
         {{HubContentArn}}
```