通过vllm 部署qwen2 模型
主要是一个简单测试
安装vllm
- pip 模式安装
部分包比较大, 注意时间, 最好使用一个加速, 目前阿里云的似乎有限速了,可以试试清华的https://pypi.tuna.tsinghua.edu.cn/simple
python -m venv venv
source venv/bin/ac
source venv/bin/activate
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple vllm
openai兼容api 模式运行qwen2
使用modelscope 进行模型的下载
- 配置modelscope
export VLLM_USE_MODELSCOPE=True
- 运行qwen2 7b 模式
相对比较慢,所以推荐配置上边的东西,同时会进行模型的下载,模型都比较大
python -m vllm.entrypoints.openai.api_server \
--model qwen/Qwen2-7B-Instruct \
--host 0.0.0.0 \
--port 8080
可能的问题:
ImportError('libcuda.so.1: cannot open shared object file: No such file or directory'), 这个目前属于waring ,暂时可以不用处理
缺少modelscope,因为配置了VLLM_USE_MODELSCOPE
所以还需要安装modelscope pip install -i https://pypi.tuna.tsinghua.edu.cn/simple modelscope
而且可能还会有提示缺少nvidia 驱动相关的,安装处理如下
cuda.repo
[cuda-rhel9-x86_64]
name=cuda-rhel9-x86_64
baseurl=https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64
enabled=1
gpgcheck=1
gpgkey=https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/D42D0685.pub
安装
sudo dnf install epel-release
sudo dnf clean all
sudo dnf install nvidia-driver nvidia-settings cuda-drivers
// 注意之后reboot 下系统
ValueError: Bfloat16 is only supported on GPUs with compute capability of at least 8.0. Your Tesla T4 GPU has compute capability 7.5. You can use float16 instead by explicitly setting thedtype
flag in CLI, for example: --dtype=half
运行配置参数修改
python -m vllm.entrypoints.openai.api_server \
--model qwen/Qwen2-7B-Instruct \
--api-key qwen2demo \
--host 0.0.0.0 \
--dtype half \
--port 8080
Nvidia 内核模块加载问题,可选的通过自己配置下
sudo dkms autoinstall sudo modprobe nvidia
之后可以通过nvidia-smi 或者lsmod |grepnvidia 进行验证内核模块是否加载成功
- api 访问
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen2-7B-Instruct",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "LoRA 是什么"}
]
}'
- gpu 信息查看
说明
vllm 比较适合进行多机多卡运行模式,对于单机模式,ollama 还是优先选择,至少比较简单快速,对于多节点部署模式需要依赖ray,同时注意GPU 版本的选择,推荐还是使用较新的,老版本的,处理就是慢, 关于GPU 配置部分ollama 的安装shell 还是很值得学习参考的
参考资料
https://docs.vllm.ai/en/stable/getting_started/quickstart.html
https://www.modelscope.cn/home
https://www.modelscope.cn/models/qwen/Qwen2-7B-Instruct/summary
https://docs.vllm.ai/en/stable/serving/distributed_serving.html
https://docs.vllm.ai/en/stable/serving/env_vars.html
https://discuss.luxonis.com/d/3868-libcudaso1-issue-in-colab/5
https://stackoverflow.com/questions/54249577/importerror-libcuda-so-1-cannot-open-shared-object-file
https://github.com/vllm-project/vllm/issues/1369
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-07-19 jprofiler 提供的几个方便工具
2022-07-19 通过graylog output 模式进行graylog的联邦以及升级处理
2022-07-19 记一次graylog 日志不能写入的问题解决
2021-07-19 cube.js 一些未来计划开发的新特性
2021-07-19 npm optionalDependencies 依赖处理
2020-07-19 openresty docker 镜像集成gor
2020-07-19 goreplay v1.1.0 支持pro特性docker 镜像