# llama.cpp 服务启动 + 推理任务 自动化脚本:启动 llama.cpp 模型服务,等待就绪后执行推理任务。 ## 文件 | 文件 | 说明 | |------|------| | `llama_inference.sh` | 主脚本 | ## 用法 ```bash # 1. 编辑脚本,修改配置区域 vim llama_inference.sh # 2. 运行 ./llama_inference.sh ``` ## 配置项 脚本顶部配置区域: ```bash LLAMA_CMD="./llama-server -m /path/to/model.gguf --port 8080" # 启动命令 LLAMA_PORT="8080" # 服务端口 HEALTH_URL="http://localhost:${LLAMA_PORT}/health" # 健康检查地址 MAX_WAIT=300 # 最长等待秒数 # 推理任务 TASKS=( 'curl -s http://localhost:8080/completion -d "{\"prompt\": \"你好\", \"n_predict\": 50}"' ) ``` ## 逻辑 1. 后台启动 llama.cpp 服务 2. 轮询健康检查接口等待服务就绪 3. 依次执行 TASKS 数组里的推理任务 4. 完成后可选择关闭服务 --- *黄庄4号程序员*