diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..4fdbea5 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,89 @@ +name: Build & Release libspconv + +on: + workflow_dispatch: + inputs: + tag: + description: 'release tag' + required: false + default: '' + text: + description: 'release body' + required: false + default: '' + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + build: + name: Build libspconv + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - cuda: cuda11.4 + image: nvcr.io/nvidia/cuda:11.4.3-devel-ubuntu20.04 + - cuda: cuda11.8 + image: nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04 + container: + image: ${{ matrix.image }} + + steps: + - name: Install git + run: | + apt-get update + apt-get install -y git + git --version + + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Build libspconv + run: | + chmod +x ./scripts/setup_env.sh + ./scripts/setup_env.sh + chmod +x ./scripts/build.sh + ./scripts/build.sh + ls -lh build/ + + - name: Find built tar.gz + if: ${{ github.event_name != 'pull_request' }} + id: artifact + run: | + FILE=$(ls build/libspconv-*.tar.gz) + if [ -z "$FILE" ]; then + echo "No build/libspconv-*.tar.gz found!" + exit 1 + fi + FILENAME=$(basename "$FILE") + echo "filepath=$FILE" >> $GITHUB_OUTPUT + echo "filename=$FILENAME" >> $GITHUB_OUTPUT + echo "Found artifact: $FILENAME" + + - name: Upload artifact + if: ${{ github.event_name != 'pull_request' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact.outputs.filename }} + path: ${{ steps.artifact.outputs.filepath }} + + - name: Create Release + if: ${{ github.event_name != 'pull_request' && github.event.inputs.tag != '' }} + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.event.inputs.tag }} + name: libspconv ${{ github.event.inputs.tag }} + body: | + ${{ github.event.inputs.text }} + files: ${{ steps.artifact.outputs.filepath }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0499a7e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "spconv"] + path = spconv + url = https://github.com/traveller59/spconv.git +[submodule "cumm"] + path = cumm + url = https://github.com/FindDefinition/cumm.git diff --git a/cumm b/cumm new file mode 160000 index 0000000..7ff78af --- /dev/null +++ b/cumm @@ -0,0 +1 @@ +Subproject commit 7ff78afcf0070fef7ef3215762cd531f5aa5802e diff --git a/patches/spconv_v2.3.6.patch b/patches/spconv_v2.3.6.patch new file mode 100644 index 0000000..dbab125 --- /dev/null +++ b/patches/spconv_v2.3.6.patch @@ -0,0 +1,27 @@ +diff --git a/example/libspconv/run_build.sh b/example/libspconv/run_build.sh +index e3b873c..d61e9cc 100644 +--- a/example/libspconv/run_build.sh ++++ b/example/libspconv/run_build.sh +@@ -4,11 +4,14 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + + git clone https://github.com/FindDefinition/cumm.git $SCRIPT_DIR/cumm + +-export CUMM_CUDA_VERSION=11.4 # cuda version, required but only used for flag selection when build libspconv. ++export CUMM_CUDA_VERSION=$1 + export CUMM_DISABLE_JIT=1 + export SPCONV_DISABLE_JIT=1 + export CUMM_INCLUDE_PATH="\${CUMM_INCLUDE_PATH}" # if you use cumm as a subdirectory, you need this to find cumm includes. +-export CUMM_CUDA_ARCH_LIST="7.5;8.6" # cuda arch flags ++export CUMM_CUDA_ARCH_LIST=$2 ++ ++echo "CUMM_CUDA_VERSION=${CUMM_CUDA_VERSION}" ++echo "CUMM_CUDA_ARCH_LIST=${CUMM_CUDA_ARCH_LIST}" + + python -m spconv.gencode --include=$SCRIPT_DIR/spconv/include --src=$SCRIPT_DIR/spconv/src --inference_only=True + +@@ -16,4 +19,4 @@ python -m spconv.gencode --include=$SCRIPT_DIR/spconv/include --src=$SCRIPT_DIR/ + mkdir -p $SCRIPT_DIR/build + cd $SCRIPT_DIR/build + cmake .. +-cmake --build $SCRIPT_DIR/build --config Release -j 8 # --verbose ++cmake --build $SCRIPT_DIR/build --config Release -j$(nproc) diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..e2734ad --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e + +CUDA_VERSION=$(nvcc --version | grep release | sed -E 's/.*release ([0-9]+\.[0-9]+).*/\1/') +CUDA_MAJOR=${CUDA_VERSION_RAW%.*} +CUDA_MINOR=${CUDA_VERSION_RAW#*.} + +CUDA_ARCH_LIST="8.0;8.6" + +if [[ "$CUDA_MAJOR" -gt 11 ]] || [[ "$CUDA_MAJOR" -eq 11 && "$CUDA_MINOR" -gt 4 ]]; then + CUDA_ARCH_LIST="${CUDA_ARCH_LIST};8.9" +fi + +export CUMM_CUDA_VERSION=${CUDA_VERSION} +export CUMM_DISABLE_JIT=1 +export CUMM_CUDA_ARCH_LIST=${CUDA_ARCH_LIST} + +pip3 install -e cumm +pip3 install -e spconv + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +PROJECT_DIR=$(dirname $SCRIPT_DIR) +ln -s $PROJECT_DIR/cumm $PROJECT_DIR/spconv/example/libspconv/cumm + +cd $PROJECT_DIR/spconv + +ARCH="$(uname -m)" +VERSION="$(git describe --tags --dirty --always)" + +git apply $PROJECT_DIR/patches/spconv_v2.3.6.patch +bash example/libspconv/run_build.sh ${CUDA_VERSION} ${CUDA_ARCH_LIST} + +PKG_NAME=libspconv-${VERSION}-${ARCH}-cuda${CUDA_VERSION} +PKG_DIR=${PROJECT_DIR}/build/${PKG_NAME} + +echo "[INFO] Packaging ${PKG_NAME}" + +rm -rf ${PKG_DIR} +mkdir -p ${PKG_DIR} +mkdir -p ${PKG_DIR}/include +mkdir -p ${PKG_DIR}/lib + +# headers +cp -r example/libspconv/spconv/include/* ${PKG_DIR}/include/ +cp -r example/libspconv/cumm/include/* ${PKG_DIR}/include/ + +# library +cp example/libspconv/build/spconv/src/libspconv.so ${PKG_DIR}/lib/ + +cd ${PROJECT_DIR}/build + +tar -czvf ${PKG_NAME}.tar.gz -C ${PKG_DIR} . + +rm -rf ${PKG_DIR} + +echo "[DONE] ${PKG_NAME}.tar.gz generated" diff --git a/scripts/setup_env.sh b/scripts/setup_env.sh new file mode 100755 index 0000000..0b0aaf9 --- /dev/null +++ b/scripts/setup_env.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +apt-get update && \ +apt-get install python3.8-dev python3-pip wget curl -y +update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + +wget https://github.com/Kitware/CMake/releases/download/v3.27.9/cmake-3.27.9-linux-x86_64.tar.gz +tar -xzf cmake-3.27.9-linux-x86_64.tar.gz +mv cmake-3.27.9-linux-x86_64 /opt/cmake +ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake \ No newline at end of file diff --git a/spconv b/spconv new file mode 160000 index 0000000..125a194 --- /dev/null +++ b/spconv @@ -0,0 +1 @@ +Subproject commit 125a194d895b1bc3ad6ff907bc72641548397b32