安装SGLang
- 方式一:使用开源社区发布的预编译安装包。
该方式由pip根据SGLang官方发布包中的依赖元数据自动解析依赖,适合直接使用开源社区默认依赖组合的场景。安装完成后仍需执行安装验证,确认PyTorch CUDA能力和sglang-kernel均可正常使用。
1 2 3 4 5
export CUDA_HOME=/usr/local/cuda-13.0 export PATH=$CUDA_HOME/bin:$PATH export LD_LIBRARY_PATH=$CUDA_HOME/lib64:${LD_LIBRARY_PATH:-} python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install sglang==0.5.10 sglang-kernel==0.4.1
- 方式二:使用本地自构建安装包。
该方式用于复用前面已确认的CUDA版本PyTorch。--no-deps不是跳过依赖要求,而是将依赖安装改为显式管理,避免安装SGLang时的依赖解析过程替换PyTorch版本。安装完成后,应再次确认torch.backends.cuda.is_built()和torch.cuda.is_available()均为True。
1 2 3 4 5 6 7 8 9 10 11 12
export CUDA_HOME=/usr/local/cuda-13.0 export PATH=$CUDA_HOME/bin:$PATH export LD_LIBRARY_PATH=$CUDA_HOME/lib64:${LD_LIBRARY_PATH:-} python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install \ typing_extensions filelock fsspec jinja2 networkx sympy mpmath numpy packaging \ tqdm requests aiohttp fastapi uvicorn pydantic orjson pyzmq psutil pillow \ sentencepiece safetensors tokenizers transformers==5.3.0 pybase64 setproctitle \ partial_json_parser diskcache msgspec interegular lark pycountry pycryptodomex \ gguf openai anthropic prometheus-client uvloop watchfiles soundfile tiktoken IPython python3 -m pip install --no-deps sglang-kernel==0.4.1 python3 -m pip install --no-deps sglang==0.5.10
如果使用本地自构建wheel,将最后两行替换为实际wheel文件路径。1 2
python3 -m pip install --force-reinstall --no-deps /path/to/sglang_kernel-0.4.1-*.whl python3 -m pip install --force-reinstall --no-deps /path/to/sglang-0.5.10-*.whl
父主题: 安装指南