Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions cumm
Submodule cumm added at 7ff78a
27 changes: 27 additions & 0 deletions patches/spconv_v2.3.6.patch
Original file line number Diff line number Diff line change
@@ -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)
57 changes: 57 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions scripts/setup_env.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions spconv
Submodule spconv added at 125a19