基于容器搭建本地开发vllm 环境(python代码部分)和向社区提交pr

1 拉取镜像和创建容器

docker pull vllm/vllm-openai:latest

docker run -d --name vllm-dev \
  --gpus all \
  --ipc=host \
  --network=host \
  --shm-size=32g \
  -v /data/:/data/ \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  -e HF_TOKEN=$HF_TOKEN \
  --entrypoint sleep \
  vllm/vllm-openai:latest infinity

2 安装ssh,vscode、pycharm、cursor等ide远程连接容器

pycharm 可以通过 JetBrains Gateway 2025.3.2 远程连接

#!/bin/bash

set -ex

apt clean
apt update
apt install -y passwd openssh-server
# 设置root用户密码
echo "设置root用户密码..."
echo "root:Linziming1-" | chpasswd
# 配置SSH服务
echo "配置SSH服务..."
# 启用TCP转发
sed -i 's/^#AllowTcpForwarding yes/AllowTcpForwarding yes/' /etc/ssh/sshd_config
# 启用GatewayPorts
sed -i 's/^#GatewayPorts no/GatewayPorts yes/' /etc/ssh/sshd_config
# 设置SSH端口变量(可修改此变量来更改端口)
SSH_PORT=${SSH_PORT:-6068}
# 配置SSH认证
sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config
# 添加端口配置(若不存在)
if ! grep -q "^Port $SSH_PORT" /etc/ssh/sshd_config; then
    # 删除旧的Port配置(如果存在)
    sed -i '/^Port /d' /etc/ssh/sshd_config
    echo "Port $SSH_PORT" >> /etc/ssh/sshd_config
fi
# 生成SSH密钥并重启服务
echo "初始化SSH服务..."
ssh-keygen -A
service ssh restart
echo "所有配置完成!root密码已设置,SSH服务已启动(监听端口$SSH_PORT)"

3 fork vllm代码仓,拉取代码和本地安装vllm(python部分,不涉及算子c++代码安装)

参考https://docs.vllm.com.cn/en/latest/getting_started/installation/gpu/#build-wheel-from-source

pip install uv
uv venv
source .venv/bin/activate

服务器里面可能会有网络,证书问题

git clone https://github.com/vllm-project/vllm.git
cd vllm
VLLM_USE_PRECOMPILED=1 uv pip install --editable .

4 修改vllm代码,添加ut用例,验证用例,跑pre-commit

set -ex 

.venv/bin/pre-commit run ruff-check --files \
  vllm/sampling_params.py \
  vllm/entrypoints/openai/chat_completion/protocol.py \
  vllm/entrypoints/openai/completion/protocol.py \
  tests/entrypoints/openai/chat_completion/test_thinking_token_budget_validation.py \
  tests/v1/logits_processors/test_correctness.py

.venv/bin/pre-commit run ruff-format --files \
  vllm/sampling_params.py \
  vllm/entrypoints/openai/chat_completion/protocol.py \
  vllm/entrypoints/openai/completion/protocol.py \
  tests/entrypoints/openai/chat_completion/test_thinking_token_budget_validation.py \
  tests/v1/logits_processors/test_correctness.py

5 commit和push

Signed-off-by 必填

git commit --no-verify -m "[Bugfix] [Reasoning] Reject invalid thinking_token_budget values

Signed-off-by: xxx <xxx@126.com>"

具体可以参考pr https://github.com/vllm-project/vllm/pull/43402

posted @ 2026-05-25 20:18  linzm14  阅读(17)  评论(0)    收藏  举报