

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 部署 JumpStart 模型
<a name="deploy-jumpstart-model"></a>

您可以使用 CLI 或 SDK 部署預先訓練的 JumpStart 模型以進行推論。

## 使用 CLI
<a name="deploy-jumpstart-cli"></a>

執行下列命令來部署 JumpStart 模型：

```
hyp create hyp-jumpstart-endpoint \
  --version 1.0 \
  --model-id deepseek-llm-r1-distill-qwen-1-5b \
  --instance-type ml.g5.8xlarge \
  --endpoint-name endpoint-test-jscli
```

## 使用開發套件
<a name="deploy-jumpstart-sdk"></a>

使用以下內容建立 Python 指令碼：

```
from sagemaker.hyperpod.inference.config.hp_jumpstart_endpoint_config import Model, Server, SageMakerEndpoint, TlsConfig
from sagemaker.hyperpod.inference.hp_jumpstart_endpoint import HPJumpStartEndpoint

model=Model(
    model_id='deepseek-llm-r1-distill-qwen-1-5b'
)

server=Server(
    instance_type='ml.g5.8xlarge',
)

endpoint_name=SageMakerEndpoint(name='{{<endpoint-name>}}')

# create spec
js_endpoint=HPJumpStartEndpoint(
    model=model,
    server=server,
    sage_maker_endpoint=endpoint_name
)
```

## 調用端點
<a name="invoke-jumpstart-endpoint"></a>

### 使用 CLI
<a name="invoke-jumpstart-cli"></a>

使用範例輸入測試端點：

```
hyp invoke hyp-jumpstart-endpoint \
    --endpoint-name endpoint-jumpstart \
    --body '{"inputs":"What is the capital of USA?"}'
```

### 使用開發套件
<a name="invoke-jumpstart-sdk"></a>

將以下程式碼新增至您的 Python 指令碼。

```
data = '{"inputs":"What is the capital of USA?"}'
response = js_endpoint.invoke(body=data).body.read()
print(response)
```

## 管理端點
<a name="manage-jumpstart-endpoint"></a>

### 使用 CLI
<a name="manage-jumpstart-cli"></a>

列出並檢查端點：

```
hyp list hyp-jumpstart-endpoint
hyp get hyp-jumpstart-endpoint --name endpoint-jumpstart
```

### 使用開發套件
<a name="manage-jumpstart-sdk"></a>

將以下程式碼新增至您的 Python 指令碼。

```
endpoint_iterator = HPJumpStartEndpoint.list()
for endpoint in endpoint_iterator:
    print(endpoint.name, endpoint.status)

logs = js_endpoint.get_logs()
print(logs)
```

## 清除資源
<a name="cleanup-jumpstart-resources"></a>

完成後，請刪除端點以避免不必要的成本。

### 使用 CLI
<a name="cleanup-jumpstart-cli"></a>

```
hyp delete hyp-jumpstart-endpoint --name endpoint-jumpstart
```

### 使用開發套件
<a name="cleanup-jumpstart-sdk"></a>

```
js_endpoint.delete()
```

## 後續步驟
<a name="jumpstart-next-steps"></a>

現在您已訓練 PyTorch 模型、將其部署為自訂端點，以及使用 HyperPod 的 CLI 和 SDK 部署 JumpStart 模型，請探索進階功能：
+ **多節點訓練**：跨多個執行個體擴展訓練
+ **自訂容器**：建置特殊化的訓練環境
+ **與 SageMaker 管道整合**：自動化您的 ML 工作流程
+ **進階監控**：設定自訂指標和警示

如需更多範例和進階組態，請造訪 [SageMaker HyperPod GitHub 儲存庫](https://github.com/aws/amazon-sagemaker-examples)。