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

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.dtcms.com/a/194230.html

相关文章:

  • yocto项目例子
  • 美创科技针对《银行保险机构数据安全管理办法》解读
  • 武汉火影数字全息剧秀制作:科技与艺术的梦幻联动
  • RAG数据处理:PDF/HTML
  • OpenCV CUDA模块中矩阵操作------降维操作
  • 22、能源监控与优化 - 数据中心模拟 - /能源管理组件/data-center-energy-monitoring
  • OCCT知识笔记之OCAF框架详解
  • CVE-2017-8046 漏洞深度分析
  • 【学习笔记】机器学习(Machine Learning) | 第七章|神经网络(1)
  • C语言水仙花数
  • 多通道电源管理芯片在分布式能源系统中的优化策略
  • 敏捷-第二章 敏捷宣言与原则
  • AI神经网络降噪算法在语音通话产品中的应用优势与前景分析
  • 我用 Appuploader绕过 Mac,成功把 iOS 应用上线了 App Store
  • 兰亭妙微设计:为生命科技赋予人性化的交互语言
  • duxapp 2025-03-29 更新 编译结束的复制逻辑等
  • 机器学习模型(4/4课时):超参数
  • Zephyr OS Nordic芯片的Flash 操作
  • idea启用lombok
  • 罗杰斯高频板技术解析:低损耗基材如何定义 5G 通信未来
  • Java 后端给前端传Long值,精度丢失的问题与解决
  • Java—— Stream流
  • 前端批量下载文件打包为zip
  • 机器学习知识自然语言处理入门
  • 基于PXIE 总线架构的Kintex UltraScale 系列FPGA 高性能数据预处理板卡
  • 黑马k8s(九)
  • 链表的中间结点数据结构oj题(力扣876)
  • 容器化-k8s-介绍及下载安装教程
  • python的家教课程管理系统
  • 等离子模块【杀菌消毒】