驱动 >=530.30.02
vLLM 最新版 + CUDA 12.1
高吞吐量 LLM 推理引擎,生产级 Docker 配置
配置摘要
框架
vLLM 最新版
CUDA 版本
12.1
Python 支持
3.10, 3.11, 3.12
最低驱动
>=530.30.02
说明: 传统稳定版本
安装命令
pip install vllm vLLM 最新版 特性
- PagedAttention 高效 KV 缓存管理
- 连续批处理实现最大吞吐量
- 张量并行支持多 GPU 推理
- 兼容 OpenAI 的 API 服务器
- 支持 50+ 模型架构
性能: 相比 HuggingFace Transformers 吞吐量提升可达 24 倍
最佳用途
适用场景
- 生产级 LLM API 服务
- 高吞吐量聊天机器人后端
- 批量推理管道
- 最小显存占用的多模型服务
CUDA 12.1 优势
- A100 和 V100 部署
- 经济高效的推理
- 与旧系统的最大兼容性
生成 Dockerfile
配置选项
本地 GPU 或 CPU 环境
传统稳定版本
需要 NVIDIA 驱动版本 >=530.30.02
Dockerfile
1# syntax=docker/dockerfile:12# ^ Required for BuildKit cache mounts and advanced features34# Generated by DockerFit (https://tools.eastondev.com/docker)5# VLLM latest + CUDA 12.1 | Python 3.116# Multi-stage build for optimized image size78# ==============================================================================9# Stage 1: Builder - Install dependencies and compile10# ==============================================================================11FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 AS builder1213# Build arguments14ARG DEBIAN_FRONTEND=noninteractive1516# Environment variables17ENV PYTHONUNBUFFERED=118ENV PYTHONDONTWRITEBYTECODE=119ENV TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0"2021# Install Python 3.11 from deadsnakes PPA (Ubuntu 22.04)22RUN apt-get update && apt-get install -y --no-install-recommends \23 software-properties-common \24 && add-apt-repository -y ppa:deadsnakes/ppa \25 && apt-get update && apt-get install -y --no-install-recommends \26 python3.11 \27 python3.11-venv \28 python3.11-dev \29 build-essential \30 git \31 ninja-build32 && rm -rf /var/lib/apt/lists/*3334# Create virtual environment35ENV VIRTUAL_ENV=/opt/venv36RUN python3.11 -m venv $VIRTUAL_ENV37ENV PATH="$VIRTUAL_ENV/bin:$PATH"3839# Upgrade pip40RUN pip install --no-cache-dir --upgrade pip setuptools wheel4142# Install vLLM with BuildKit cache43# Pre-install packaging for potential source builds44RUN --mount=type=cache,target=/root/.cache/pip \45 pip install packaging && \46 pip install vllm4748# Install project dependencies49COPY requirements.txt .50RUN --mount=type=cache,target=/root/.cache/pip \51 pip install -r requirements.txt5253# ==============================================================================54# Stage 2: Runtime - Minimal production image55# ==============================================================================56FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 AS runtime5758# Labels59LABEL maintainer="Generated by DockerFit"60LABEL version="latest"61LABEL description="VLLM latest + CUDA 12.1"6263# Environment variables64ENV PYTHONUNBUFFERED=165ENV PYTHONDONTWRITEBYTECODE=166ENV NVIDIA_VISIBLE_DEVICES=all67ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility6869# Install Python 3.11 runtime from deadsnakes PPA (Ubuntu 22.04)70RUN apt-get update && apt-get install -y --no-install-recommends \71 software-properties-common \72 && add-apt-repository -y ppa:deadsnakes/ppa \73 && apt-get update && apt-get install -y --no-install-recommends \74 python3.11 \75 libgomp1 \76 ninja-build77 && apt-get remove -y software-properties-common \78 && apt-get autoremove -y \79 && rm -rf /var/lib/apt/lists/*8081# Create non-root user for security82ARG USERNAME=appuser83ARG USER_UID=100084ARG USER_GID=$USER_UID85RUN groupadd --gid $USER_GID $USERNAME \86 && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME8788# Copy virtual environment from builder89COPY --from=builder --chown=$USERNAME:$USERNAME /opt/venv /opt/venv90ENV VIRTUAL_ENV=/opt/venv91ENV PATH="$VIRTUAL_ENV/bin:$PATH"9293# Set working directory94WORKDIR /app9596# Copy application code97COPY --chown=$USERNAME:$USERNAME . .9899# Switch to non-root user100USER $USERNAME101102# Expose port103EXPOSE 8000104105# Default command106CMD ["python", "main.py"]
🚀 推荐部署
高性能 GPU 与 AI 云服务器
为您的 Docker 容器提供强大的 NVIDIA 算力支持,支持 A100/H100,全球 32 个机房可选。
- 支持 NVIDIA A100/H100 GPU 实例
- 按小时计费,测试成本低至 $0.004/h
- 全球 32+ 数据中心,极低访问延迟
- 一键运行容器化应用与裸金属服务器
常见问题
vLLM 需要多少 GPU 显存?
GPU 显存需求取决于模型大小:
- • 7B 模型: 16GB+ (T4, A10G)
- • 13B 模型: 24GB+ (L4, A10G)
- • 70B 模型: 80GB+ (A100, H100)
vLLM 支持张量并行,可用于多 GPU 部署。
如何使用 vLLM 提供模型服务?
启动兼容 OpenAI API 的 vLLM 服务:
python -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-3.2-3B-Instruct --port 8000
该服务提供与 OpenAI API 兼容的接口。
Blackwell 配置是什么?
Blackwell 配置针对 NVIDIA 最新的 B200 和 GB200 GPU 优化:
- • 需要 CUDA 12.8+
- • 使用 PyTorch nightly 构建
- • 支持 FP4 精度以获得最大吞吐量