Qwen1.5-72B-Chat用vllm部署【踩坑记录经验贴】

Qwen1.5-72B-Chat用vllm部署

前置准备

4张A100
Ubuntu 20
conda环境

坑点1-nvidia环境和cuda环境统一

这里可以看重新安装nvidia和cuda环境

//验证pytorch-cuda可用性
python
>>>import torch
>>>torch.cuda.is_available()

这里返回true就可以

安装vllm

坑点2-如果空间不大且很难扩容

pip空间不足问题
去到root目录下把cache清掉
rm -r ./.cache/
删了还是不足:pip install --no-cache-dir somepackage
如果自己有代理科学上网可以这样
pip install --proxy=http://127.0.0.1:10809 --no-cache-dir modelscope
如果没有可以用阿里云的pip镜像
pip install -i https://mirrors.aliyun.com/pypi/simple/ --no-cache-dir

pip安装vllm
pip install  -i https://mirrors.aliyun.com/pypi/simple/ --no-cache-dir vllm

拉取模型

git clone https://www.modelscope.cn/qwen/Qwen1.5-72B-Chat.git

用vllm启动http服务

python -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --port 8000 --gpu-memory-utilization 0.9 --max-model-len 29856 --served-model-name Qwen1.5-72B-Chat  --model Qwen1.5-72B-Chat  --tensor-parallel-size 4

坑:–model这里需要填你模型下载下来的位置。ex:/home/xxx/Qwen1.5-72B-Chat
坑:如果服务器开了防火墙记得开对应的端口

 --host 0.0.0.0 #IP
 --port 8000 #端口
 --gpu-memory-utilization 0.9 #占用GPU内存部分
 --max-model-len 29856  #上下文长度
 --model Qwen1.5-72B-Chat #模型文件位置
 --tensor-parallel-size 4 #指定4张卡

在这里插入图片描述

验证调用:
curl

curl --location --request POST 'http://127.0.0.1:8000/v1/chat/completions' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "Qwen1.5-72B-Chat",
  "messages": [
    {
      "role": "user",
      "content": "你好!请你介绍一下自己"
    }
  ]
}'

在这里插入图片描述
或者使用python验证

from openai import OpenAI
# Set OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"

client = OpenAI(
    api_key=openai_api_key,
    base_url=openai_api_base,
)

chat_response = client.chat.completions.create(
    model="Qwen1.5-72B-Chat",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Tell me something about large language models."},
    ]
)
print("Chat response:", chat_response)
  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值