build_linux_wheel.sh 1.99 KB
Newer Older
muyangli's avatar
muyangli committed
1
2
3
4
5
6
7
8
9
#!/bin/bash
# Modified from https://github.com/sgl-project/sglang/blob/main/sgl-kernel/build.sh
set -ex
PYTHON_VERSION=$1
TORCH_VERSION=$2
CUDA_VERSION=$3
MAX_JOBS=${4:-} # optional
PYTHON_ROOT_PATH=/opt/python/cp${PYTHON_VERSION//.}-cp${PYTHON_VERSION//.}

10
11
12
13
14
15
16
17
18
# Check if TORCH_VERSION is 2.5 or 2.6 and set the corresponding versions for TORCHVISION and TORCHAUDIO
if [ "$TORCH_VERSION" == "2.5" ]; then
  TORCHVISION_VERSION="0.20"
  TORCHAUDIO_VERSION="2.5"
  echo "TORCH_VERSION is 2.5, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
elif [ "$TORCH_VERSION" == "2.6" ]; then
  TORCHVISION_VERSION="0.21"
  TORCHAUDIO_VERSION="2.6"
  echo "TORCH_VERSION is 2.6, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
19
20
21
22
elif [ "$TORCH_VERSION" == "2.7" ]; then
  TORCHVISION_VERSION="0.22"
  TORCHAUDIO_VERSION="2.7"
  echo "TORCH_VERSION is 2.7, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
23
24
25
26
elif [ "$TORCH_VERSION" == "2.8" ]; then
  TORCHVISION_VERSION="0.23"
  TORCHAUDIO_VERSION="2.8"
  echo "TORCH_VERSION is 2.8, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
27
else
28
  echo "TORCH_VERSION is not 2.5, 2.6, 2.7 or 2.8, no changes to versions."
29
30
fi

muyangli's avatar
muyangli committed
31
32
docker run --rm \
    -v "$(pwd)":/nunchaku \
33
    pytorch/manylinux2_28-builder:cuda${CUDA_VERSION} \
muyangli's avatar
muyangli committed
34
35
36
37
    bash -c "
    cd /nunchaku && \
    rm -rf build && \
    gcc --version && g++ --version && \
38
    ${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//.} && \
muyangli's avatar
muyangli committed
39
40
41
42
43
    ${PYTHON_ROOT_PATH}/bin/pip install build ninja wheel setuptools && \
    export NUNCHAKU_INSTALL_MODE=ALL && \
    export NUNCHAKU_BUILD_WHEELS=1 && \
    export MAX_JOBS=${MAX_JOBS} && \
    ${PYTHON_ROOT_PATH}/bin/python -m build --wheel --no-isolation
Muyang Li's avatar
Muyang Li committed
44
    "