侧边栏壁纸
博主头像
Eoser's page! 博主等级

@学习@生活@自己

  • 累计撰写 118 篇文章
  • 累计创建 30 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

vllm运行huggingface的deepseek蒸馏模型

eoser
2025-02-17 / 0 评论 / 0 点赞 / 4 阅读 / 0 字

anaconda安装配置,以及huggingface镜像配置不在这里介绍了,可以看看《BitNet运行大模型折腾事件》

创建一个运行环境

conda create -n vllm python=3.12 -y
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

GPU安装vllm

# 安装vllm
pip install vllm

CPU安装vllm

官方文档:https://docs.vllm.ai/en/latest/getting_started/installation/cpu/index.html

1.cpu版本需要自己编译,先安装编译环境

sudo apt-get update  -y
sudo apt-get install -y gcc-12 g++-12 libnuma-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12

2.拉取代码

git clone --recursive http://github.com/vllm-project/vllm.git

3.编译cpu的依赖

cd vllm
pip install --upgrade pip

pip install "cmake>=3.26" wheel packaging ninja "setuptools-scm>=8" numpy
# pytorch 下载太慢,通过 --proxy 加本地的外网代理加速
pip install -v -r requirements-cpu.txt --extra-index-url https://download.pytorch.org/whl/cpu --proxy=http://192.168.3.2:10083

4.编译安装

VLLM_TARGET_DEVICE=cpu python setup.py install

下载大模型


export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --local-dir deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
# 运行大模型
vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --trust-remote-code --host=0.0.0.0 --port=8080 --max-model-len=1024 --max-num-batched-tokens=6000 --enable-prefix-caching
# 测试大模型
curl http://localhost:8080/v1/chat/completions     -H "Content-Type: application/json"     -d '{
        "model": "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
        "messages": [
            {"role": "system", "content": "你是一个全能助手。"},
            {"role": "user", "content": "谁赢了2020年的世界杯?"}
        ]
    }'

0

评论区