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

发布于:2024-05-17 ⋅ 阅读:(220) ⋅ 点赞:(0)

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)

网站公告

今日签到

点亮在社区的每一天
去签到