当前位置: 首页 > article >正文

Qwen2.5-VL模型sft微调和使用vllm部署

本文的server.py和req.py代码参见:https://github.com/zysNLP/quickllm
配套课程《AIGC大模型理论与工业落地实战》;Deepseek相关课程更新中

1. 安装相关docker镜像:nvcr.io/nvidia/pytorch:25.02-py3

docker pull nvcr.io/nvidia/pytorch:25.02-py3

2. 启动docker

docker run -idt --network host --shm-size=64g --name vllm --restart=always --gpus all -v /data2/users/yszhang/quickllm:/quickllm nvcr.io/nvidia/pytorch:25.02-py3 /bin/bash

3. 在魔塔中下载相关模型

pip install modelscope
modelscope download --model Qwen/Qwen2.5-VL-7B-Instruct --local_dir /data2/users/yszhang/quickllm/qwen2.5-vl-instruct

4.进入docker容器,安装conda环境;下载LLama-Factory

docker exec -it vllm /bin/bash
cd /quickllm
bash Miniconda3-latest-Linux-x86_64.sh
conda create -n sft python=3.11
conda activate sftgit clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
pip install -e ".[torch,metrics]"

5. 启动LLaMA-Factory的web ui

llamafactory-cli webui

6. 训练模型、融合lora参数

# 融合后的模型路径/quickllm/LLaMA-Factory/qwen2.5-mmlm0513;以webui的实际调整为准llamafactory-cli train \--stage sft \--do_train True \--model_name_or_path /quickllm/qwen2.5-vl-instruct \--preprocessing_num_workers 16 \--finetuning_type lora \--template qwen2_vl \--flash_attn auto \--dataset_dir data \--dataset mllm_demo \--cutoff_len 2048 \--learning_rate 5e-05 \--num_train_epochs 3.0 \--max_samples 100000 \--per_device_train_batch_size 2 \--gradient_accumulation_steps 8 \--lr_scheduler_type cosine \--max_grad_norm 1.0 \--logging_steps 5 \--save_steps 100 \--warmup_steps 0 \--packing False \--report_to none \--output_dir saves/Qwen2.5-VL-7B-Instruct/lora/train_2025-05-16-05-48-02 \--bf16 True \--plot_loss True \--trust_remote_code True \--ddp_timeout 180000000 \--include_num_input_tokens_seen True \--optim adamw_torch \--lora_rank 8 \--lora_alpha 16 \--lora_dropout 0 \--lora_target all

7. 创建conda环境安装vllm/transformers

conda create -n vllm python=3.11
conda activate vllm
pip install vllm -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install transformers -i https://pypi.tuna.tsinghua.edu.cn/simple

8. 启动vllm+fastapi服务

python server.py

9. 请求服务

python req.py

模型实测速度 

使用batch的方式请求同一条数据;速度1000条/20s。(这里因为是同一条图文数据所以速度会更快,如果用不同的图文数据速度会稍慢一些,但是也非常快!)

Using a slow image processor as `use_fast` is unset and a slow processor was saved with this model. `use_fast=True` will be the default behavior in v4.52, even if the model was saved with a slow processor. This will result in minor differences in outputs. You'll still be able to use a slow processor with `use_fast=False`.
INFO:     Started server process [19930]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:7868 (Press CTRL+C to quit)
Processed prompts: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00,  7.68it/s, est. speed input: 899.09 toks/s, output: 430.33 toks/s]
INFO:     127.0.0.1:60618 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00,  7.58it/s, est. speed input: 886.83 toks/s, output: 424.46 toks/s]
INFO:     127.0.0.1:60620 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00,  7.58it/s, est. speed input: 887.41 toks/s, output: 424.74 toks/s]
INFO:     127.0.0.1:44776 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:02<00:00, 47.28it/s, est. speed input: 5532.30 toks/s, output: 2647.93 toks/s]
INFO:     127.0.0.1:47144 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [00:16<00:00, 62.39it/s, est. speed input: 7299.34 toks/s, output: 3493.70 toks/s]
INFO:     127.0.0.1:38156 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [00:15<00:00, 62.51it/s, est. speed input: 7313.23 toks/s, output: 3500.35 toks/s]
INFO:     127.0.0.1:50830 - "POST /chat HTTP/1.1" 200 OK
Processed prompts: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [00:16<00:00, 62.35it/s, est. speed input: 7295.48 toks/s, output: 3491.85 toks/s]

http://www.lryc.cn/news/2378968.html

相关文章:

  • python打卡DAY22
  • 【教程】Docker更换存储位置
  • 鸿蒙Next API17学习新特性之组件可见区域变化事件新增支持设置事件的回调参数,限制它的执行间隔
  • AI大模型从0到1记录学习 mysql day23
  • spring -MVC-02
  • 深入解析 React 的 useEffect:从入门到实战
  • 通过Ollama读取模型
  • C#控制流
  • 永久免费,特殊版本!
  • Canva 推出自有应用生成器以与 Bolt 和 Lovable 竞争
  • Matrix-Game:键鼠实时控制、实时生成的游戏生成模型(论文代码详细解读)
  • MySQL 5.7在CentOS 7.9系统下的安装(下)——给MySQL设置密码
  • 机器学习笔记2
  • AgentCPM-GUI,清华联合面壁智能开源的端侧GUI智能体模型
  • Go语言实现链式调用
  • 重排序模型解读 mxbai-rerank-base-v2 强大的重排序模型
  • 期望是什么:(无数次的均值,结合概率)21/6=3.5
  • uniapp-vue3项目中引入高德地图的天气展示
  • 容器化-k8s-介绍及下载安装教程
  • lc42接雨水
  • 通义千问-langchain使用构建(三)
  • uniapp自动构建pages.json的vite插件
  • 系统漏洞扫描服务:维护网络安全的关键与服务原理?
  • nlf loss 学习笔记
  • 【Redis】零碎知识点(易忘 / 易错)总结回顾
  • 基于three.js 全景图片或视频开源库Photo Sphere Viewer
  • LangPDF: Empowering Your PDFs with Intelligent Language Processing
  • OpenVLA (2) 机器人环境和环境数据
  • 代码复现5——VLMaps
  • Ocean: Object-aware Anchor-free Tracking