部署 JumpStart 模型 - Amazon SageMaker AI

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

部署 JumpStart 模型

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

使用 CLI

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

hyp create hyp-jumpstart-endpoint \ --version 1.0 \ --model-id deepseek-llm-r1-distill-qwen-1-5b \ --model-version 2.0.4 \ --instance-type ml.g5.8xlarge \ --endpoint-name endpoint-jumpstart \ --tls-output-s3-uri s3://tls-bucket-inf1-beta2

使用開發套件

使用下列內容建立 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", model_version="2.0.4" ) server = Server( instance_type="ml.g5.8xlarge" ) endpoint_name = SageMakerEndpoint(name="endpoint-jumpstart") tls_config = TlsConfig(tls_certificate_output_s3_uri="s3://tls-bucket-inf1-beta2") js_endpoint = HPJumpStartEndpoint( model=model, server=server, sage_maker_endpoint=endpoint_name, tls_config=tls_config ) js_endpoint.create()

調用端點

使用 CLI

使用範例輸入測試端點:

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

使用開發套件

將下列程式碼新增至您的 Python 指令碼:

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

管理端點

使用 CLI

列出並檢查端點:

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

使用開發套件

將下列程式碼新增至您的 Python 指令碼:

endpoint_iterator = HPJumpStartEndpoint.list() for endpoint in endpoint_iterator: print(endpoint.name, endpoint.status) logs = js_endpoint.get_logs() print(logs)

清除資源

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

使用 CLI

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

使用開發套件

js_endpoint.delete()

後續步驟

現在您已訓練 PyTorch 模型、將其部署為自訂端點,以及使用 HyperPod 的 CLI 和 SDK 部署 JumpStart 模型,請探索進階功能:

  • 多節點訓練:跨多個執行個體擴展訓練

  • 自訂容器:建置專門的訓練環境

  • 與 SageMaker 管道整合:自動化您的 ML 工作流程

  • 進階監控:設定自訂指標和提醒

如需更多範例和進階組態,請造訪 SageMaker HyperPod GitHub 儲存庫