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

vllm 本地部署qwen2.5/Qwen2.5-32B-Instruct-AWQ模型

vllm 本地部署qwen2.5/Qwen2.5-32B-Instruct-AWQ 量化版 模型

因 ollama 并发效果没有 vllm 好,目前只能使用 vllm 部署

( 基于 docker )
目前作者环境如下:

驱动CUDA显卡型号显卡块数
560.35.0312.6.14090 48G8

下载模型

modelscope download --model Qwen/Qwen2.5-32B-Instruct-AWQ  --local_dir  /data/qwen2.5/Qwen2.5-32B-Instruct-AWQ

开始配置

docker 配置

vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.cloudmessage.top","https://kfp63jaj.mirror.aliyuncs.com","https://j47dskil.mirror.aliyuncs.com"],
"ipv6": false,
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"},"runtimes": {"nvidia": {"path": "/usr/bin/nvidia-container-runtime","runtimeArgs": []}},
"default-runtime": "nvidia",
"data-root": "/data/docker"
}

docker 安装 vllm

###镜像比较大16G多,还是先拉下来再运行
docker pull vllm/vllm-openai:latest

运行 程序

--dtype float16 \  # 混合精度推理
--block-size 16 \  #  KV缓存块大小	
--use-v2-block-manager \  # 新版显存管理器	
--max-num-batched-tokens 8192 \ # 最大批处理tokens(4096-16384)
--max-num-seqs 32 最大并发请求数# 以此类推 8 块卡
# 第一块卡 显存占用了 70%,留了30% 给 openwebui 使用docker run --runtime nvidia --gpus "device=0" --name vllm-qwen2.5-32b_AWQ \
--restart always \
-v /data/qwen2.5:/data/qwen2.5 \
-v /data/vllm_cache:/root/.cache/vllm \
-p 8000:8000 \
-e CUDA_VISIBLE_DEVICES=0 \
-d vllm/vllm-openai:latest \
--model /data/qwen2.5/Qwen2.5-32B-Instruct-AWQ \
--dtype float16 \
--block-size 16 \
--use-v2-block-manager \
--gpu-memory-utilization 0.7 \
--max-num-batched-tokens 8192 \
--max-num-seqs 32 \
--max_model_len 8192docker run --runtime nvidia --gpus "device=1" --name vllm-qwen2.5-32b_AWQ_01 \
--restart always \
-v /data/qwen2.5:/data/qwen2.5 \
-v /data/vllm_cache:/root/.cache/vllm \
-p 8111:8000 \
-e CUDA_VISIBLE_DEVICES=0 \
-d vllm/vllm-openai:latest \
--model /data/qwen2.5/Qwen2.5-32B-Instruct-AWQ \
--dtype float16 \
--block-size 16 \
--use-v2-block-manager \
--gpu-memory-utilization 1 \
--max-num-batched-tokens 8192 \
--max-num-seqs 32 \
--max_model_len 8192

测试程序

# 创建虚拟环境
conda create -n qwenvl python=3.11 -y
conda activate qwenvl# 安装模块pip install vllm -i https://pypi.tuna.tsinghua.edu.cn/simplepip install git+https://github.com/huggingface/transformers acceleratepip install torch  -i https://pypi.tuna.tsinghua.edu.cn/simplepip install flash-attn --no-build-isolation  -i https://pypi.tuna.tsinghua.edu.cn/simplepip install "huggingface_hub[hf_transfer]"  -i https://pypi.tuna.tsinghua.edu.cn/simplepip install modelscope  -i https://pypi.tuna.tsinghua.edu.cn/simplepip install qwen_vl_utils  -i https://pypi.tuna.tsinghua.edu.cn/simple
from openai import OpenAI
import time# 记录开始时间
start_time = time.time()try:client = OpenAI(base_url="http://192.168.0.88:8110/v1",api_key="NOT_NEED")# 测试列出可用模型print("Available models:", [m.id for m in client.models.list().data])# 调用模型response = client.chat.completions.create(model="/data/qwen2.5/Qwen2.5-32B-Instruct-AWQ",messages=[{"role": "system", "content": "You are a helpful assistant."},# {"role": "user", "content": "Give me a short introduction to large language model."}{"role": "user", "content": "请始终使用中文回答用户问题"}],max_tokens=512,timeout=30.0)# 输出结果和耗时print("\nResponse:", response.choices[0].message.content)print(f"\nTime used: {time.time()-start_time:.2f} seconds")except Exception as e:print(f"Error: {str(e)}")print(f"Time used: {time.time()-start_time:.2f} seconds")

openwebui

docker run --gpus all -d \
-p 13000:8080 \
--add-host=host.docker.internal:192.168.0.100 \
-v open-webui-data:/app/backend/data \
-e OLLAMA_API_BASE_URL=http://192.168.0.100:8000 \
--name open-webui-vllm \
--restart always \
registry.cn-shenzhen.aliyuncs.com/funet8/open-webui:cuda

配置docker 容器中配置

docker exec -it  openwebui-vllm /bin/bash
设置完成之后,去到服务器上,进到这个docker容器中
apt update
apt install -y iputils-ping vim net-tools telnet
# 查看IP
ifconfigvim /etc/hosts
192.168.0.100   host.docker.internal退出容器
在 iptables 中 放开所有
iptables -I INPUT -s 172.17.0.11 -p tcp --dport 8110 -j ACCEPT
service iptables save 													默认的是访问8000端口,如果想改为其他端口
docker exec -it open-webui /bin/bash
进到容器中
/app/backend# vim config.py
:%s/11434/11449/g  (改为你想修改的端口即可)
docker restart open-webui

登录到 openwebui

http://192.168.0.100:13000 # 注册账户,通过自己的邮箱创建就行
登录上来发现如果找不到模型,如下配置即可
点击 左下角的设置

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

刷新,在重新进网页,发现模型已经有了也可以查看 docker 日志
docker logs -f  openwebui

相关文章:

  • Crawl4AI:为大语言模型打造的开源网页数据采集工具
  • AI Agent系列(九) -Data Agent(数据分析智能体)
  • 【无人机】PX4飞控怎么烧写加载固件,更新固件方法,详细流程
  • seaborn库详解
  • pandas库详解
  • 【web服务_负载均衡Nginx】一、Nginx 基础与核心概念解析
  • 使用 reverse-sourcemap 工具反编译 Vue 项目
  • 如何通俗理解transformer架构
  • Vue中v-if和v-show区别
  • 探索Web3平台的数据安全和保护机制
  • 蓝光三维扫描技术:高效精密测量相机镜头底座注塑件
  • 在 Power BI Desktop 中设置视觉对象查询限制
  • 基于labview的钢琴程序设计
  • 算法之贪心算法
  • Python + 链上数据可视化:让区块链数据“看得懂、用得上”
  • ESP32- 开发笔记- 硬件设计-ESP32-C3基本电路
  • Windows平台使用Docker部署Neo4j
  • 《MySQL:MySQL数据库的基本操作》
  • 利用互斥锁或者利用逻辑过期解决缓存击穿问题
  • C# 类型、存储和变量(实例化类型)
  • 中美经贸高层会谈在瑞士日内瓦开始举行
  • 可量产9MWh超大容量储能系统亮相慕尼黑,宁德时代:大储技术迈入新时代
  • 欧盟决意与俄罗斯能源彻底决裂之际,美国谋划新生意:进口俄气对欧转售
  • 中俄弘扬正确二战史观:缅怀历史,重拾初心,阻止悲剧重演
  • 妻子藏匿一岁幼儿一年多不让丈夫见,法院发出人格权侵害禁令
  • 第1现场 | 50多年来首次!印度举行大规模民防演习