From a222945df21fb89244c666ae4db781cebec19406 Mon Sep 17 00:00:00 2001 From: Elfie Guo <164945471+elfiegg@users.noreply.github.com> Date: Thu, 10 Apr 2025 15:21:02 -0700 Subject: [PATCH] Update Makefile / build script to avoid installing incompatible torch dependency (#5245) --- sgl-kernel/Makefile | 8 ++++---- sgl-kernel/build.sh | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/sgl-kernel/Makefile b/sgl-kernel/Makefile index e8e0910cd..73b15be2c 100644 --- a/sgl-kernel/Makefile +++ b/sgl-kernel/Makefile @@ -10,7 +10,7 @@ check-deps: ## Check and install required Python formatting dependencies @command -v black >/dev/null 2>&1 || (echo "Installing black..." && pip install black) install-deps: ## Install Python formatting tools (isort and black) - pip install isort black + pip install scikit-build-core isort black tree: ## Show project directory structure @tree --prune -I "__pycache__|*.egg-info|*.so|build|3rdparty|dist" @@ -23,10 +23,10 @@ ln: submodule ## Create compilation database install: submodule ## Install package in development mode - @pip install -e . + @pip install -e . --no-build-isolation -build: submodule ## Build and install wheel package - @rm -rf dist/* || true && export MAX_JOBS=$(nproc) && uv build --wheel -Cbuild-dir=build . --verbose --color=always && pip3 install dist/*whl --force-reinstall --no-deps +build: install-deps submodule ## Build and install wheel package + @rm -rf dist/* || true && export MAX_JOBS=$(nproc) && uv build --wheel -Cbuild-dir=build . --verbose --color=always --no-build-isolation && pip3 install dist/*whl --force-reinstall --no-deps clean: ## Remove build artifacts @rm -rf build dist *.egg-info diff --git a/sgl-kernel/build.sh b/sgl-kernel/build.sh index 6748030ef..608cbb647 100755 --- a/sgl-kernel/build.sh +++ b/sgl-kernel/build.sh @@ -18,14 +18,28 @@ docker run --rm \ -v $(pwd):/sgl-kernel \ ${DOCKER_IMAGE} \ bash -c " + # Install CMake (version >= 3.26) - Robust Installation + export CMAKE_VERSION_MAJOR=3.31 + export CMAKE_VERSION_MINOR=1 + echo \"Downloading CMake from: https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz\" + wget https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz + tar -xzf cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz + mv cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64 /opt/cmake + export PATH=/opt/cmake/bin:\$PATH + + # Debugging CMake + echo \"PATH: \$PATH\" + which cmake + cmake --version + ${PYTHON_ROOT_PATH}/bin/${TORCH_INSTALL} && \ - ${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir ninja setuptools==75.0.0 wheel==0.41.0 numpy uv && \ + ${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir ninja setuptools==75.0.0 wheel==0.41.0 numpy uv scikit-build-core && \ export TORCH_CUDA_ARCH_LIST='7.5 8.0 8.9 9.0+PTX' && \ export CUDA_VERSION=${CUDA_VERSION} && \ mkdir -p /usr/lib/x86_64-linux-gnu/ && \ ln -s /usr/local/cuda-${CUDA_VERSION}/targets/x86_64-linux/lib/stubs/libcuda.so /usr/lib/x86_64-linux-gnu/libcuda.so && \ cd /sgl-kernel && \ ls -la ${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages/wheel/ && \ - PYTHONPATH=${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages ${PYTHON_ROOT_PATH}/bin/python -m uv build --wheel -Cbuild-dir=build . --color=always && \ + PYTHONPATH=${PYTHON_ROOT_PATH}/lib/python${PYTHON_VERSION}/site-packages ${PYTHON_ROOT_PATH}/bin/python -m uv build --wheel -Cbuild-dir=build . --color=always --no-build-isolation && \ ./rename_wheels.sh "