赞
踩
vLLM是一个快速且易于使用的LLM推理和服务库。
vLLM具有以下特点:
vLLM具有灵活性,易于与以下组件一起使用:
由于vllm不支持Windows系统,下文将讲述如何在WSL2(linux系统)上部署
WSL安装可参考站内该文章WSL2安装(详细过程)
注:WSL版本必须为2,否则后续无法正常加载显卡驱动
vllm官网建议安装cuda12.1,与conda管理python包。
linux-x86
安装包下载到本地即可。下载到指定目录后,例如我下载在D盘中,进入wsl2终端cd /mnt/d
,bash Anaconda3-2024.02-1-Linux-x86_64.sh
即可开始安装。安装过程一路回车输入yes
即可,注最后一步建议输yes
,会将conda环境变量写入~/.bashrc
文件中。vim ~/.condarc
,输入如下内容channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda create -n vllm python=3.9 -y
conda activate vllm
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install vllm
安装vllm包。pip3 install torch torchvision torchaudio
。nvidia-smi
应有正常回显。vllm官方使用cuda12.1版本,使用deb(network)安装方式安装,有如下命令。
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda
安装完毕后将cuda写入环境变量。
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
使用nvcc -V
有正常回显,cuda安装成功,验证cuda能否正常使用cd /usr/local/cuda/extras/demo_suite/ && ./deviceQuery && cd -
,出现PASS打屏即保证cuda功能正常。
python3 -m vllm.entrypoints.openai.api_server --model /data/gemma_test/gemma-2b/ --dtype float16 --served-model-name gemma-2b --host 127.0.0.1 --port 8080
出现如下打屏,说明服务端启动成功。
另起一终端输入如下命令,可得到模型输出。
curl http://127.0.0.1:8080/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-2b",
"prompt": "请你介绍一下你自己"
}'
由于本人显卡算力有限,vllm无法以gemma-2b训练的bf16格式加载权重,导致精度有所损失,问题回答结果不太正常。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。