5 分钟上手 ServerlessLLM:从安装到部署的完整新手教程

📅 2026/7/12 9:27:01
5 分钟上手 ServerlessLLM:从安装到部署的完整新手教程
5 分钟上手 ServerlessLLM从安装到部署的完整新手教程【免费下载链接】ServerlessLLMServerlessLLM is a distributed model deployment system that supports efficient multi-checkpoint saving, offering fast cold starts and serverless deployment capabilities项目地址: https://gitcode.com/openeuler/ServerlessLLM前往项目官网免费下载https://ar.openeuler.org/ar/ServerlessLLM 是一款分布式模型部署系统支持高效的多检查点保存提供快速冷启动和无服务器部署能力。本教程将帮助新手用户在 5 分钟内完成从安装到部署的全过程轻松体验 ServerlessLLM 的强大功能。准备工作部署前的必要条件 在开始部署 ServerlessLLM 之前请确保您的系统满足以下要求Docker已安装在您的系统上。您可以从 Docker 官方网站获取安装包。ServerlessLLM CLI通过pip install serverless-llm命令安装。GPU至少需要一张 NVIDIA GPU。如果您有多个 GPU可以相应调整docker-compose.yml文件。NVIDIA Docker Toolkit这是 Docker 利用 NVIDIA GPU 的必要组件可按照官方安装指南进行配置。快速启动搭建 ServerlessLLM 集群 ⚡我们将使用 Docker Compose 来简化 ServerlessLLM 的设置过程快速搭建一个包含头节点和单个工作节点的最小集群。第一步下载 Docker Compose 文件首先创建一个目录用于存放 ServerlessLLM 的 Docker 配置文件并下载docker-compose.yml# 创建目录并进入 mkdir serverless-llm-docker cd serverless-llm-docker # 克隆仓库获取 docker-compose.yml git clone https://gitcode.com/openeuler/ServerlessLLM cp ServerlessLLM/examples/docker/docker-compose.yml .第二步配置模型存储路径创建一个用于存储模型的目录并设置MODEL_FOLDER环境变量export MODEL_FOLDER/path/to/your/models请将/path/to/your/models替换为您实际打算存储模型的路径该目录将被挂载到 Docker 容器中。第三步启动服务使用 Docker Compose 启动 ServerlessLLM 服务docker compose up -d启动后您可以通过以下命令验证服务是否就绪docker logs sllm_head当看到类似以下输出时说明服务已准备就绪... INFO: Uvicorn running on http://0.0.0.0:8343 (Press CTRLC to quit) (FcfsScheduler pid1604) INFO 05-26 15:40:49 fcfs_scheduler.py:54] Starting FCFS scheduler (FcfsScheduler pid1604) INFO 05-26 15:40:49 fcfs_scheduler.py:111] Starting control loopServerlessLLM 架构概览展示了头节点和工作节点的集群结构模型部署使用 sllm 命令部署模型 设置LLM_SERVER_URL环境变量指向 ServerlessLLM 服务export LLM_SERVER_URLhttp://127.0.0.1:8343然后使用sllm命令部署模型这里以部署facebook/opt-1.3b为例sllm deploy --model facebook/opt-1.3b注意该命令会从 Hugging Face Model Hub 下载模型可能需要一些时间。您可以通过--model参数指定任何来自 Hugging Face Model Hub 的模型名称。部署成功后您将看到类似以下输出INFO 08-01 07:38:12 deploy.py:36] Deploying model facebook/opt-1.3b with default configuration. INFO 08-01 07:39:00 deploy.py:49] Model registered successfully.模型加载过程展示了 ServerlessLLM 加载模型的流程模型查询通过 OpenAI 兼容 API 进行交互 部署完成后您可以使用任何 OpenAI API 客户端来查询模型。以下是使用curl命令进行查询的示例curl $LLM_SERVER_URL/v1/chat/completions \ -H Content-Type: application/json \ -d { model: facebook/opt-1.3b, messages: [ {role: system, content: You are a helpful assistant.}, {role: user, content: What is your name?} ] }预期输出{id:chatcmpl-8b4773e9-a98b-41db-8163-018ed3dc65e2,object:chat.completion,created:1720183759,model:facebook/opt-1.3b,choices:[{index:0,message:{role:assistant,content:system: You are a helpful assistant.\nuser: What is your name?\nsystem: I am a helpful assistant.\n},logprobs:null,finish_reason:stop}],usage:{prompt_tokens:16,completion_tokens:26,total_tokens:42}}%清理工作删除模型和停止服务 如果需要删除已部署的模型可以执行以下命令sllm delete facebook/opt-1.3b要停止 ServerlessLLM 服务使用docker compose down总结通过本教程您已经成功完成了 ServerlessLLM 的安装、集群搭建、模型部署和查询的全过程。ServerlessLLM 提供了高效的模型部署和管理能力让您可以轻松地在本地环境中体验大规模语言模型的魅力。如需了解更多详细信息您可以参考官方文档docs/stable/getting_started.md。【免费下载链接】ServerlessLLMServerlessLLM is a distributed model deployment system that supports efficient multi-checkpoint saving, offering fast cold starts and serverless deployment capabilities项目地址: https://gitcode.com/openeuler/ServerlessLLM创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考