Lychee-Rerank-MM部署教程:后台nohup运行+日志监控与PID管理

📅 发布时间:2026/7/5 15:39:20 👁️ 浏览次数:
Lychee-Rerank-MM部署教程:后台nohup运行+日志监控与PID管理
Lychee-Rerank-MM部署教程后台nohup运行日志监控与PID管理1. 项目概述Lychee-Rerank-MM是基于Qwen2.5-VL的多模态重排序模型专门用于图文检索场景的精排任务。这个7B参数的模型采用BF16精度推理由哈工大深圳NLP团队开发能够处理文本到文本、文本到图像、图像到文本以及图像到图像等多种模态组合的重排序需求。2. 环境准备2.1 硬件要求GPU显存建议16GB及以上存储空间模型文件约15GB确保有足够空间内存建议32GB以上以获得最佳性能2.2 软件依赖确保系统中已安装以下基础组件# 检查Python版本 python3 --version # 需要3.8 # 检查PyTorch安装 python3 -c import torch; print(torch.__version__) # 需要2.03. 部署步骤3.1 获取模型文件模型默认路径为/root/ai-models/vec-ai/lychee-rerank-mm如果路径不存在需要先下载模型mkdir -p /root/ai-models/vec-ai cd /root/ai-models/vec-ai git clone https://www.modelscope.cn/vec-ai/lychee-rerank-mm.git3.2 安装依赖进入项目目录安装所需依赖cd /root/ai-models/vec-ai/lychee-rerank-mm pip install -r requirements.txt4. 运行与管理4.1 启动服务推荐使用以下三种方式之一启动服务# 方式1使用启动脚本推荐 ./start.sh # 方式2直接运行 python app.py # 方式3后台运行生产环境推荐 nohup python app.py /tmp/lychee_server.log 21 4.2 进程管理查找运行中的进程ps aux | grep python app.py输出示例user 12345 0.5 2.1 1234567 89012 pts/0 Sl 14:30 0:05 python app.py停止服务kill 12345 # 替换为实际的PID查看日志tail -f /tmp/lychee_server.log4.3 自动重启脚本创建监控脚本monitor.sh确保服务持续运行#!/bin/bash while true; do if ! pgrep -f python app.py /dev/null; then echo $(date): Service not running, restarting... /var/log/lychee_monitor.log nohup python /root/lychee-rerank-mm/app.py /tmp/lychee_server.log 21 fi sleep 60 done赋予执行权限并启动监控chmod x monitor.sh nohup ./monitor.sh /dev/null 21 5. 服务验证5.1 检查服务状态curl http://localhost:7860/health预期返回{status:healthy}5.2 测试API接口curl -X POST http://localhost:7860/api/v1/rerank \ -H Content-Type: application/json \ -d { instruction: Given a web search query, retrieve relevant passages that answer the query, query: What is the capital of China?, documents: [The capital of China is Beijing., Shanghai is the largest city in China.] }6. 性能优化建议6.1 批量处理对于大量文档使用批量模式可显著提升效率# 示例Python代码 import requests url http://localhost:7860/api/v1/batch_rerank data { instruction: Given a product image and description, retrieve similar products, query: product_image.jpg, # 或文本查询 documents: [doc1.txt, doc2.jpg, ...] # 支持混合模态 } response requests.post(url, jsondata)6.2 参数调整根据硬件配置调整以下参数max_length控制处理文本的最大长度默认3200batch_size批量处理时的文档数量flash_attention确保启用以获得最佳性能7. 常见问题解决7.1 模型加载失败检查步骤# 确认模型路径 ls /root/ai-models/vec-ai/lychee-rerank-mm # 检查GPU可用性 nvidia-smi # 验证依赖版本 pip list | grep torch7.2 内存不足解决方案减少batch_size使用--precision bf16参数增加GPU内存或使用多卡推理7.3 服务无响应排查方法# 检查端口占用 netstat -tulnp | grep 7860 # 检查日志错误 grep -i error /tmp/lychee_server.log8. 总结本教程详细介绍了Lychee-Rerank-MM模型的部署和管理方法重点包括环境配置硬件要求与依赖安装服务部署多种启动方式与后台运行进程管理PID查找、停止服务和日志监控性能优化批量处理与参数调整建议故障排查常见问题解决方法通过本指南您可以轻松地在生产环境中部署和管理这个强大的多模态重排序模型为图文检索应用提供精准的排序能力。获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。