ci_install_dependency.sh 2.9 KB
Newer Older
1
#!/bin/bash
2
# Install the dependency in CI.
3
set -euxo pipefail
Lianmin Zheng's avatar
Lianmin Zheng committed
4

5
IS_BLACKWELL=${IS_BLACKWELL:-0}
Lianmin Zheng's avatar
Lianmin Zheng committed
6
CU_VERSION="cu128"
Cheng Wan's avatar
Cheng Wan committed
7

8
# Kill existing processes
9
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
bash "${SCRIPT_DIR}/../killall_sglang.sh"
11
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-}"
12

Lianmin Zheng's avatar
Lianmin Zheng committed
13
14
15
# Clear torch compilation cache
python3 -c 'import os, shutil, tempfile, getpass; cache_dir = os.environ.get("TORCHINDUCTOR_CACHE_DIR") or os.path.join(tempfile.gettempdir(), "torchinductor_" + getpass.getuser()); shutil.rmtree(cache_dir, ignore_errors=True)'

16
17
18
19
20
21
22
23
24
# Install apt packages
apt install -y git libnuma-dev

# Install uv
if [ "$IS_BLACKWELL" = "1" ]; then
    # The blackwell CI runner has some issues with pip and uv,
    # so we can only use pip with `--break-system-packages`
    PIP_CMD="pip"
    PIP_INSTALL_SUFFIX="--break-system-packages"
fzyzcjy's avatar
fzyzcjy committed
25

26
    # Clean up existing installations
Lianmin Zheng's avatar
Lianmin Zheng committed
27
    $PIP_CMD uninstall -y flashinfer_python sgl-kernel sglang vllm torch $PIP_INSTALL_SUFFIX || true
28
29
else
    # In normal cases, we use uv, which is much faster than pip.
Cheng Wan's avatar
Cheng Wan committed
30
    pip install --upgrade pip
31
32
    pip install uv
    export UV_SYSTEM_PYTHON=true
33

34
35
36
37
    PIP_CMD="uv pip"
    PIP_INSTALL_SUFFIX="--index-strategy unsafe-best-match"

    # Clean up existing installations
Lianmin Zheng's avatar
Lianmin Zheng committed
38
    $PIP_CMD uninstall flashinfer_python sgl-kernel sglang vllm torch || true
39
fi
Xiaoyu Zhang's avatar
Xiaoyu Zhang committed
40
41

# Install the main package
42
$PIP_CMD install -e "python[dev]" --extra-index-url https://download.pytorch.org/whl/${CU_VERSION} $PIP_INSTALL_SUFFIX
Xiaoyu Zhang's avatar
Xiaoyu Zhang committed
43

44
45
46
# Install router for pd-disagg test
SGLANG_ROUTER_BUILD_NO_RUST=1 $PIP_CMD install -e "sgl-router" $PIP_INSTALL_SUFFIX

Lianmin Zheng's avatar
Lianmin Zheng committed
47
# Install sgl-kernel
48
49
50
SGL_KERNEL_VERSION_FROM_KERNEL=$(grep -Po '(?<=^version = ")[^"]*' sgl-kernel/pyproject.toml)
SGL_KERNEL_VERSION_FROM_SRT=$(grep -Po -m1 '(?<=sgl-kernel==)[0-9A-Za-z\.\-]+' python/pyproject.toml)
echo "SGL_KERNEL_VERSION_FROM_KERNEL=${SGL_KERNEL_VERSION_FROM_KERNEL} SGL_KERNEL_VERSION_FROM_SRT=${SGL_KERNEL_VERSION_FROM_SRT}"
51

52
53
if [ "${CUSTOM_BUILD_SGL_KERNEL:-}" = "true" ]; then
    ls -alh sgl-kernel/dist
Lianmin Zheng's avatar
Lianmin Zheng committed
54
    $PIP_CMD install sgl-kernel/dist/sgl_kernel-${SGL_KERNEL_VERSION_FROM_KERNEL}-cp310-abi3-manylinux2014_x86_64.whl --force-reinstall $PIP_INSTALL_SUFFIX
55
else
Lianmin Zheng's avatar
Lianmin Zheng committed
56
    $PIP_CMD install sgl-kernel==${SGL_KERNEL_VERSION_FROM_SRT} --force-reinstall $PIP_INSTALL_SUFFIX
57
58
fi

59
# Show current packages
60
$PIP_CMD list
61

Xiaoyu Zhang's avatar
Xiaoyu Zhang committed
62
# Install additional dependencies
63
$PIP_CMD install mooncake-transfer-engine==0.3.6.post1 nvidia-cuda-nvrtc-cu12 py-spy huggingface_hub[hf_xet] $PIP_INSTALL_SUFFIX
64

65
if [ "$IS_BLACKWELL" != "1" ]; then
fzyzcjy's avatar
fzyzcjy committed
66
67
    # For lmms_evals evaluating MMMU
    git clone --branch v0.3.3 --depth 1 https://github.com/EvolvingLMMs-Lab/lmms-eval.git
68
    $PIP_CMD install -e lmms-eval/ $PIP_INSTALL_SUFFIX
69

fzyzcjy's avatar
fzyzcjy committed
70
    # Install xformers
71
    $PIP_CMD install xformers --index-url https://download.pytorch.org/whl/${CU_VERSION} --no-deps $PIP_INSTALL_SUFFIX
fzyzcjy's avatar
fzyzcjy committed
72
fi
73
74

# Show current packages
75
$PIP_CMD list
Lianmin Zheng's avatar
Lianmin Zheng committed
76
python3 -c "import torch; print(torch.version.cuda)"