使用vLLM部署大模型:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
| 第73行: | 第73行: | ||
# 启动容器 | # 启动容器 | ||
docker run -d --name vllm-qwen \ | # 确保设置了 API Key | ||
export VLLM_API_KEY=$(openssl rand -hex 32) | |||
echo "你的 API Key 是: $VLLM_API_KEY" | |||
# 启动容器 | |||
sudo docker run -d --name vllm-qwen \ | |||
--gpus all \ | --gpus all \ | ||
--ipc=host \ | --ipc=host \ | ||
| 第81行: | 第86行: | ||
-e HF_HUB_OFFLINE=1 \ | -e HF_HUB_OFFLINE=1 \ | ||
-e VLLM_API_KEY=$VLLM_API_KEY \ | -e VLLM_API_KEY=$VLLM_API_KEY \ | ||
nvcr.io/nvidia/vllm:26.01-py3 \ | |||
--model /models/Qwen2.5-72B-Instruct-FP8 \ | --model /models/Qwen2.5-72B-Instruct-FP8 \ | ||
--served-model-name Qwen2.5-72B-Instruct \ | --served-model-name Qwen2.5-72B-Instruct \ | ||
| 第99行: | 第104行: | ||
--load-format fastsafetensors | --load-format fastsafetensors | ||
</source> | </source> | ||
结果报错: | |||
<pre> | |||
ERROR: This container was built for NVIDIA Driver Release 590.48 or later, but | |||
version 580.159.03 was detected and compatibility mode is UNAVAILABLE. | |||
</pre> | |||
2026年6月24日 (三) 13:27的版本
$ pip install -U "huggingface_hub[cli]"
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.这个错误是因为你正在使用 Ubuntu 23.04+、Debian 12+ 或其他遵循 PEP 668 标准的现代 Linux 发行版。系统为了保护自身稳定性,禁止直接使用 pip 向系统级 Python 环境中安装第三方包,以防止与系统包管理器(apt)发生冲突。
针对你想安装 huggingface_hub[cli] 的需求,以下是三种推荐解决方案,按推荐程度排序:
推荐使用虚拟环境(最推荐,标准做法):
这是 Python 开发的最佳实践,既能隔离依赖,又不会破坏系统环境。
创建虚拟环境:
python3 -m venv hf-env激活虚拟环境:
source hf-env/bin/activate此时你的终端提示符前会出现 (hf-env),表示已进入隔离环境。
在虚拟环境中安装:
pip install -U "huggingface_hub[cli]"使用 CLI 工具:
只要虚拟环境处于激活状态,你就可以直接使用 hf 或 huggingface-cli 命令。
下载docker镜像:
export LATEST_VLLM_VERSION=26.01-py3
docker pull nvcr.io/nvidia/vllm:${LATEST_VLLM_VERSION}确认一下:
$ sudo docker inspect nvcr.io/nvidia/vllm:${LATEST_VLLM_VERSION} | grep Architecture
"Architecture": "arm64",运行:
# 确保设置了 API Key
export VLLM_API_KEY=$(openssl rand -hex 32)
echo "你的 API Key 是: $VLLM_API_KEY"
# 启动容器
# 确保设置了 API Key
export VLLM_API_KEY=$(openssl rand -hex 32)
echo "你的 API Key 是: $VLLM_API_KEY"
# 启动容器
sudo docker run -d --name vllm-qwen \
--gpus all \
--ipc=host \
--restart unless-stopped \
-p 8000:8000 \
-v $HOME/data/models:/models \
-e HF_HUB_OFFLINE=1 \
-e VLLM_API_KEY=$VLLM_API_KEY \
nvcr.io/nvidia/vllm:26.01-py3 \
--model /models/Qwen2.5-72B-Instruct-FP8 \
--served-model-name Qwen2.5-72B-Instruct \
--host 0.0.0.0 \
--port 8000 \
--api-key $VLLM_API_KEY \
--tensor-parallel-size 1 \
--trust-remote-code \
--kv-cache-dtype fp8 \
--attention-backend flashinfer \
--gpu-memory-utilization 0.85 \
--max-model-len 32768 \
--max-num-seqs 4 \
--max-num-batched-tokens 8192 \
--enable-chunked-prefill \
--enable-prefix-caching \
--load-format fastsafetensors结果报错:
ERROR: This container was built for NVIDIA Driver Release 590.48 or later, but
version 580.159.03 was detected and compatibility mode is UNAVAILABLE.