Dockerfile 3.94 KB
Newer Older
Ying Sheng's avatar
Ying Sheng committed
1
ARG CUDA_VERSION=12.1.1
2
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04
Yineng Zhang's avatar
Yineng Zhang committed
3
ARG BUILD_TYPE=all
Ying Sheng's avatar
Ying Sheng committed
4
5
6
7
ENV DEBIAN_FRONTEND=noninteractive

RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
    && echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
Yineng Zhang's avatar
Yineng Zhang committed
8
9
10
    && apt update -y \
    && apt install software-properties-common -y \
    && add-apt-repository ppa:deadsnakes/ppa -y && apt update \
11
    && apt install python3.10 python3.10-dev -y \
Yineng Zhang's avatar
Yineng Zhang committed
12
13
    && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2 \
    && update-alternatives --set python3 /usr/bin/python3.10 && apt install python3.10-distutils -y \
14
    && apt install curl git sudo libibverbs-dev -y \
Yineng Zhang's avatar
Yineng Zhang committed
15
    && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py \
Ying Sheng's avatar
Ying Sheng committed
16
    && python3 --version \
Liangsheng Yin's avatar
Liangsheng Yin committed
17
18
    && python3 -m pip --version \
    && rm -rf /var/lib/apt/lists/* \
Yineng Zhang's avatar
Yineng Zhang committed
19
    && apt clean
Ying Sheng's avatar
Ying Sheng committed
20

21
22
23
# For openbmb/MiniCPM models
RUN pip3 install datamodel_code_generator

Ying Sheng's avatar
Ying Sheng committed
24
25
WORKDIR /sgl-workspace

26
ARG CUDA_VERSION
Yineng Zhang's avatar
Yineng Zhang committed
27
RUN python3 -m pip install --upgrade pip setuptools wheel html5lib six \
28
    && git clone --depth=1 https://github.com/sgl-project/sglang.git \
Yineng Zhang's avatar
Yineng Zhang committed
29
30
31
32
    && if [ "$CUDA_VERSION" = "12.1.1" ]; then \
         python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu121; \
       elif [ "$CUDA_VERSION" = "12.4.1" ]; then \
         python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu124; \
33
34
       elif [ "$CUDA_VERSION" = "12.5.1" ]; then \
         python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu124; \
Yineng Zhang's avatar
Yineng Zhang committed
35
36
       elif [ "$CUDA_VERSION" = "11.8.0" ]; then \
         python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu118; \
37
         python3 -m pip install sgl-kernel -i https://docs.sglang.ai/whl/cu118; \
Yineng Zhang's avatar
Yineng Zhang committed
38
39
40
       else \
         echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1; \
       fi \
41
    && cd sglang \
Yineng Zhang's avatar
Yineng Zhang committed
42
    && if [ "$BUILD_TYPE" = "srt" ]; then \
43
44
45
46
         if [ "$CUDA_VERSION" = "12.1.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[srt]" --find-links https://flashinfer.ai/whl/cu121/torch2.4/flashinfer/; \
         elif [ "$CUDA_VERSION" = "12.4.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[srt]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/; \
47
48
         elif [ "$CUDA_VERSION" = "12.5.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[srt]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/; \
49
50
         elif [ "$CUDA_VERSION" = "11.8.0" ]; then \
           python3 -m pip --no-cache-dir install -e "python[srt]" --find-links https://flashinfer.ai/whl/cu118/torch2.4/flashinfer/; \
51
           python3 -m pip install sgl-kernel -i https://docs.sglang.ai/whl/cu118; \
52
53
54
         else \
           echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1; \
         fi; \
Yineng Zhang's avatar
Yineng Zhang committed
55
       else \
56
57
58
59
         if [ "$CUDA_VERSION" = "12.1.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[all]" --find-links https://flashinfer.ai/whl/cu121/torch2.4/flashinfer/; \
         elif [ "$CUDA_VERSION" = "12.4.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/; \
60
61
         elif [ "$CUDA_VERSION" = "12.5.1" ]; then \
           python3 -m pip --no-cache-dir install -e "python[all]" --find-links https://flashinfer.ai/whl/cu124/torch2.4/flashinfer/; \
62
63
         elif [ "$CUDA_VERSION" = "11.8.0" ]; then \
           python3 -m pip --no-cache-dir install -e "python[all]" --find-links https://flashinfer.ai/whl/cu118/torch2.4/flashinfer/; \
64
           python3 -m pip install sgl-kernel -i https://docs.sglang.ai/whl/cu118; \
65
66
67
         else \
           echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1; \
         fi; \
Yineng Zhang's avatar
Yineng Zhang committed
68
69
70
       fi

RUN python3 -m pip cache purge
Ying Sheng's avatar
Ying Sheng committed
71
72

ENV DEBIAN_FRONTEND=interactive