部署环境
python 3.9.6
显卡:笔记本4080 12g显存
内存:32g
cpu:i9-14900hx
一、部署过程
1.git clone https://github.com/QwenLM/Qwen2.5-VL //下载源码,下不了就直接下载压缩包解压缩
2.pip install git+https://github.com/huggingface/transformers accelerate
3.pip install qwen-vl-utils[decord]==0.0.8
4.pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121 //安装支持 CUDA 的 PyTorch,不然跑模型不使用你的GPU
5.pip install -U gradio gradio_client //更新Gradio和Gradio Client
6.进入Qwen2.5-VL-main根目录,打开cmd终端运行:
python web_demo_mm.py --checkpoint-path "Qwen/Qwen2.5-VL-3B-Instruct"
下载完模型后浏览器打开http://localhost:7860就能访问到WebUi界面:
二、注意的地方
1.部署过程中可能发生很多依赖冲突或者找不到模块错误,只能缺什么安装什么,或者降版本,下面贴上我的pip list以供参考:
accelerate 1.0.1
aiofiles 23.2.1
annotated-types 0.7.0
anyio 4.6.2
av 12.3.0
certifi 2025.1.31
charset-normalizer 3.4.1
click 8.1.8
colorama 0.4.6
contourpy 1.1.1
cycler 0.12.1
decord 0.6.0
exceptiongroup 1.2.2
fastapi 0.115.11
ffmpy 0.5.0
filelock 3.16.1
fonttools 4.56.0
fsspec 2025.3.0
gradio 4.44.1
gradio_client 1.3.0
h11 0.14.0
httpcore 1.0.7
httpx 0.28.1
huggingface-hub 0.29.3
idna 3.10
importlib_metadata 8.5.0
importlib_resources 6.4.5
intel-openmp 2021.4.0
Jinja2 3.1.6
joblib 1.4.2
kiwisolver 1.4.7
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.9.4
mdurl 0.1.2
mkl 2021.4.0
mpmath 1.3.0
networkx 3.1
nltk 3.9.1
numpy 1.26.4
orjson 3.10.10
packaging 24.2
pandas 2.2.3
Pillow 9.5.0
pip 25.0.1
psutil 7.0.0
pydantic 2.6.2
pydantic_core 2.16.3
pydub 0.25.1
pygame 2.6.1
Pygments 2.19.1
pyparsing 3.1.4
python-dateutil 2.9.0.post0
python-multipart 0.0.20
pytz 2025.1
PyYAML 6.0.2
qwen-vl-utils 0.0.8
regex 2024.5.15
requests 2.32.3
rich 13.9.4
ruff 0.11.0
sacremoses 0.1.1
safetensors 0.5.3
semantic-version 2.10.0
setuptools 75.3.2
setuptools-rust 1.10.2
shellingham 1.5.4
six 1.17.0
sniffio 1.3.1
starlette 0.44.0
sympy 1.13.3
tbb 2021.13.1
tokenizers 0.21.1
tomlkit 0.12.0
torch 2.3.0+cu121
torchaudio 2.3.0+cu121
torchvision 0.18.0+cu121
tqdm 4.67.1
transformers 4.50.0.dev0
typer 0.15.2
typing_extensions 4.12.2
tzdata 2025.1
urllib3 2.2.3
uvicorn 0.33.0
websockets 12.0
wheel 0.45.1
zipp 3.20.2
2.如果Huggingface连不上去,可以编辑web_demo_mm.py,在头部加上:
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
3.如果运行后发生queue.Empty错误,可以打开web_demo_mm.py设置超时时间长一点:
streamer = TextIteratorStreamer(tokenizer, timeout=300.0, skip_prompt=True, skip_special_tokens=True)
最试运行后发现我的电脑运行3B模型都有点吃力,一次回答需要几十秒,分辨率大的图片会直接爆显存,但个人玩玩还是没问题的~