|
| 1 | +# If the device is Battlemage, we need to set UBUNTU_VERSION to 24.10 |
| 2 | + |
| 3 | +# Usage: docker build --build-arg UBUNTU_VERSION=24.04 --build-arg PYTHON_VERSION=3.10 -t sglang:xpu_kernel -f Dockerfile.xpu --no-cache . |
| 4 | + |
| 5 | + |
| 6 | +# Set default Ubuntu version to 24.04 |
| 7 | +FROM intel/deep-learning-essentials:2025.1.3-0-devel-ubuntu24.04 |
| 8 | + |
| 9 | +ENV DEBIAN_FRONTEND=noninteractive |
| 10 | + |
| 11 | +# Define build arguments |
| 12 | +ARG PYTHON_VERSION=3.10 |
| 13 | + |
| 14 | +# Set environment variables |
| 15 | + |
| 16 | +ARG SG_LANG_REPO=https://github.com/sgl-project/sglang.git |
| 17 | +ARG SG_LANG_BRANCH=main |
| 18 | + |
| 19 | +ARG SG_LANG_KERNEL_REPO=https://github.com/sgl-project/sgl-kernel-xpu.git |
| 20 | +ARG SG_LANG_KERNEL_BRANCH=main |
| 21 | + |
| 22 | +# Install Miniforge & PyTorch/Triton & build vllm/SGlang from source |
| 23 | +RUN curl -fsSL -v -o miniforge.sh -O https://github.com/conda-forge/miniforge/releases/download/25.1.1-0/Miniforge3-Linux-x86_64.sh && \ |
| 24 | + bash miniforge.sh -b -p ./miniforge3 && \ |
| 25 | + rm miniforge.sh && \ |
| 26 | + . ./miniforge3/bin/activate && \ |
| 27 | + conda create -y -n py${PYTHON_VERSION} python=${PYTHON_VERSION} && conda activate py${PYTHON_VERSION} && \ |
| 28 | + conda install pip && \ |
| 29 | + echo ". /miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; . /opt/intel/oneapi/setvars.sh; cd /root/" >> /root/.bashrc; |
| 30 | + |
| 31 | +# Install Miniforge & PyTorch/Triton & build vllm/SGlang from source |
| 32 | +RUN apt-get update && \ |
| 33 | + apt install -y intel-ocloc |
| 34 | + |
| 35 | +RUN --mount=type=secret,id=github_token \ |
| 36 | + cd /root && \ |
| 37 | + . /miniforge3/bin/activate && \ |
| 38 | + conda activate py${PYTHON_VERSION} && \ |
| 39 | + # . /opt/intel/oneapi/setvars.sh --force && \ |
| 40 | + # Install Torch |
| 41 | + pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu |
| 42 | + |
| 43 | +# Install vllm from source |
| 44 | +RUN --mount=type=secret,id=github_token \ |
| 45 | + cd /root && \ |
| 46 | + . /miniforge3/bin/activate && \ |
| 47 | + conda activate py${PYTHON_VERSION} && \ |
| 48 | + echo "Building vllm/sglang from source ..." && \ |
| 49 | + git clone https://github.com/zhuyuhua-v/vllm.git && \ |
| 50 | + cd vllm && \ |
| 51 | + git checkout yuhua/deepseek && \ |
| 52 | + pip install setuptools_scm --root-user-action=ignore && \ |
| 53 | + pip install setuptools==75.6.0 packaging==24.2 --root-user-action=ignore && \ |
| 54 | + VLLM_TARGET_DEVICE=xpu python setup.py install |
| 55 | + |
| 56 | +# Install SGlang from source |
| 57 | +RUN --mount=type=secret,id=github_token \ |
| 58 | + # Install vllm from source |
| 59 | + cd /root && \ |
| 60 | + . /miniforge3/bin/activate && \ |
| 61 | + conda activate py${PYTHON_VERSION} && \ |
| 62 | + echo "cloning ${SG_LANG_BRANCH} from ${SG_LANG_REPO}" && \ |
| 63 | + git clone --branch ${SG_LANG_BRANCH} --single-branch ${SG_LANG_REPO} && \ |
| 64 | + cd sglang && \ |
| 65 | + pip install -e "python[all_xpu]" --root-user-action=ignore && \ |
| 66 | + # Clone sgl-kernel and build sglang-kernel... |
| 67 | + echo "cloning ${SG_LANG_KERNEL_REPO} from ${SG_LANG_KERNEL_BRANCH}" && \ |
| 68 | + git clone --branch ${SG_LANG_KERNEL_BRANCH} --single-branch ${SG_LANG_KERNEL_REPO} && \ |
| 69 | + cd sgl-kernel-xpu && \ |
| 70 | + pip install -v . &&\ |
| 71 | + # Install required packages for sglang workloads |
| 72 | + pip install msgspec blake3 py-cpuinfo compressed_tensors gguf partial_json_parser einops --root-user-action=ignore && \ |
| 73 | + conda install libsqlite=3.48.0 -y && \ |
| 74 | + echo ". /miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; cd /root/" >> /root/.bashrc; |
| 75 | + |
| 76 | +# Set the default shell to bash |
| 77 | +SHELL ["bash", "-c"] |
| 78 | +CMD ["bash", "-c", "source /root/.bashrc && exec bash"] |
0 commit comments