本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
部署 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
使用 SDK
创建一个 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?"}'
使用 SDK
向 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
使用 SDK
向 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
使用 SDK
js_endpoint.delete()
后续步骤
现在,您已经训练了 PyTorch 模型,将其部署为自定义终端节点,并使用 HyperPod的 CLI 和 SDK 部署了 JumpStart 模型,请探索高级功能:
-
多节点训练:跨多个实例扩展训练规模
-
自定义容器:构建专门的训练环境
-
与 SageMaker 流水线集成:自动化您的机器学习工作流程
-
高级监控:设置自定义指标和警报
有关更多示例和高级配置,请访问SageMaker HyperPod GitHub 存储库