我要评分
获取效率
正确性
完整性
易理解

Environment Configuration

Before compiling and building the source code, you need to install the dependent components of the required version.

  1. Install system dependencies.
    1
    2
    3
    4
    dnf install -y \
      --setopt=install_weak_deps=False \
      --setopt=tsflags=nodocs \
      python3-pip python3-devel gcc gcc-c++ make cmake git ninja-build openblas-devel numactl-devel rust cargo
    
  2. Install the Python build tools.
    1
    python3 -m pip install --upgrade pip setuptools wheel packaging ninja cmake pybind11 scikit-build-core
    
  3. Install PyTorch of the CUDA version.
    • Method 1: Use the official precompiled wheel.
      1
      python3 -m pip install --index-url https://download.pytorch.org/whl/cu130 torch==2.11.0+cu130
      
    • Method 2: Use the locally built wheel. Replace the path with the actual wheel file path.
      1
      python3 -m pip install --force-reinstall /path/to/torch-2.11.0+cu130-*.whl
      
    • To install PyTorch of the CUDA version, you can use either of the following methods: Use the precompiled wheel released by PyTorch that matches the CUDA version, or use the locally built CUDA wheel that has been verified in the current environment. Regardless of the source you choose, before continuing with the source code build of SGLang, ensure that both torch.backends.cuda.is_built() and torch.cuda.is_available() return True.
    • The SGLang source code contains two build objects that work together: The python directory generates the main Python package of SGLang, which provides the runtime framework, APIs, and scheduling logic. The sgl-kernel directory generates the CUDA extension package, which provides high-performance operator capabilities related to GPU inference. When building the source code for GPU scenarios, you need to build and install both wheels.