本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
部署 JumpStart 模型
您可以使用 CLI 或 SDK 部署預先訓練的 JumpStart 模型以進行推論。
使用 CLI
執行下列命令來部署 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
使用開發套件
使用以下內容建立 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 )
調用端點
使用 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 儲存庫