当前位置:   article > 正文

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

qwen 1.5 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()
  • 1
  • 2
  • 3
  • 4

这里返回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
  • 1

拉取模型

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
  • 1

坑:–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张卡

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

在这里插入图片描述

验证调用:
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": "你好!请你介绍一下自己"
    }
  ]
}'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

在这里插入图片描述
或者使用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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/820649
推荐阅读
相关标签
  

闽ICP备14008679号