Skip to content

Commit 4f79ccd

Browse files
zhyncsthyecust
authored andcommitted
support sgl-kernel on blackwell (sgl-project#5074)
1 parent 5cf628d commit 4f79ccd

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

sgl-kernel/build.sh

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/bin/bash
22
set -ex
3+
34
PYTHON_VERSION=$1
45
CUDA_VERSION=$2
56
PYTHON_ROOT_PATH=/opt/python/cp${PYTHON_VERSION//.}-cp${PYTHON_VERSION//.}
7+
ENABLE_SM90A=$(( ${CUDA_VERSION%.*} >= 12 ? ON : OFF ))
68

7-
if (( ${CUDA_VERSION%.*} < 12 )); then
8-
ENABLE_SM90A=0
9+
if [ ${CUDA_VERSION} = "12.8" ]; then
10+
DOCKER_IMAGE="pytorch/manylinux2_28-builder:cuda${CUDA_VERSION}"
11+
TORCH_INSTALL="pip install --no-cache-dir --pre torch --index-url https://download.pytorch.org/whl/nightly/cu${CUDA_VERSION//.}"
912
else
10-
ENABLE_SM90A=1
13+
DOCKER_IMAGE="pytorch/manylinux-builder:cuda${CUDA_VERSION}"
14+
TORCH_INSTALL="pip install --no-cache-dir torch==2.5.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//.}"
1115
fi
1216

1317
docker run --rm \
14-
-v $(pwd):/sgl-kernel \
15-
pytorch/manylinux-builder:cuda${CUDA_VERSION} \
16-
bash -c "
17-
${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir torch==2.5.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//.} && \
18-
${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir ninja setuptools==75.0.0 wheel==0.41.0 numpy uv && \
19-
export TORCH_CUDA_ARCH_LIST='7.5 8.0 8.9 9.0+PTX' && \
20-
export CUDA_VERSION=${CUDA_VERSION} && \
21-
export SGL_KERNEL_ENABLE_BF16=1 && \
22-
export SGL_KERNEL_ENABLE_FP8=1 && \
23-
export SGL_KERNEL_ENABLE_SM90A=${ENABLE_SM90A} && \
24-
mkdir -p /usr/lib/x86_64-linux-gnu/ && \
25-
ln -s /usr/local/cuda-${CUDA_VERSION}/targets/x86_64-linux/lib/stubs/libcuda.so /usr/lib/x86_64-linux-gnu/libcuda.so && \
26-
cd /sgl-kernel && \
27-
ls -la ${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages/wheel/ && \
28-
PYTHONPATH=${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages ${PYTHON_ROOT_PATH}/bin/python -m uv build --wheel -Cbuild-dir=build . --color=always && \
29-
./rename_wheels.sh
30-
"
18+
-v $(pwd):/sgl-kernel \
19+
${DOCKER_IMAGE} \
20+
bash -c "
21+
${PYTHON_ROOT_PATH}/bin/${TORCH_INSTALL} && \
22+
${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir ninja setuptools==75.0.0 wheel==0.41.0 numpy uv && \
23+
export TORCH_CUDA_ARCH_LIST='7.5 8.0 8.9 9.0+PTX' && \
24+
export CUDA_VERSION=${CUDA_VERSION} && \
25+
mkdir -p /usr/lib/x86_64-linux-gnu/ && \
26+
ln -s /usr/local/cuda-${CUDA_VERSION}/targets/x86_64-linux/lib/stubs/libcuda.so /usr/lib/x86_64-linux-gnu/libcuda.so && \
27+
cd /sgl-kernel && \
28+
ls -la ${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages/wheel/ && \
29+
PYTHONPATH=${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages ${PYTHON_ROOT_PATH}/bin/python -m uv build --wheel -Cbuild-dir=build . --color=always && \
30+
./rename_wheels.sh
31+
"

0 commit comments

Comments
 (0)