Make the build backward compatible with libtorch version < 2.2 #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: OpenSplat (Ubuntu) | |
on: | |
push: | |
branches: | |
- fix-libtorch-2.2 | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened ] | |
release: | |
types: [ published, edited ] | |
jobs: | |
build: | |
name: ${{ matrix.os }}-${{ matrix.cuda-version }}-torch-${{ matrix.torch-version }}-${{ matrix.cmake-build-type }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, ubuntu-20.04] # [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04] | |
torch-version: [2.1.2, 2.2.1] # [1.12.0, 1.13.0, 2.0.0, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1] | |
cuda-version: ['cu118', 'cu121'] # ['cpu', 'cu113', 'cu116', 'cu117'] | |
cmake-build-type: [Release] # [Debug, ClangTidy] | |
exclude: | |
- cuda-version: cu118 | |
- torch-version: 2.2.1 | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/ccache | |
CCACHE_BASEDIR: ${{ github.workspace }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Ubuntu | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
build-essential \ | |
cmake \ | |
ninja-build \ | |
libopencv-dev \ | |
wget | |
- name: Install ccache | |
run: | | |
wget -nv https://github.com/ccache/ccache/releases/download/v4.9.1/ccache-4.9.1-linux-x86_64.tar.xz | |
sudo tar xf ccache-4.9.1-linux-x86_64.tar.xz -C /usr/bin --strip-components=1 --no-same-owner ccache-4.9.1-linux-x86_64/ccache | |
rm -f ccache-*-linux-x86_64.tar.xz | |
ccache --version | |
- name: Install CUDA ${{ matrix.cuda-version }} | |
if: ${{ matrix.cuda-version != 'cpu' }} | |
run: | | |
bash .github/workflows/cuda/${{ runner.os }}.sh ${{ matrix.cuda-version }} | |
- name: Free disk space | |
if: ${{ matrix.os == 'ubuntu-20.04' }} | |
run: | | |
df -h | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc || true | |
df -h | |
- name: Install libtorch ${{ matrix.torch-version }}+${{ matrix.cuda-version }} | |
run: | | |
wget --no-check-certificate -nv https://download.pytorch.org/libtorch/${{ matrix.cuda-version }}/libtorch-cxx11-abi-shared-with-deps-${{ matrix.torch-version }}%2B${{ matrix.cuda-version }}.zip -O libtorch.zip | |
unzip -q ${{ github.workspace }}/libtorch.zip -d ${{ github.workspace }}/ | |
rm ${{ github.workspace }}/libtorch.zip | |
- name: Cache Build | |
uses: actions/cache@v4 | |
id: cache-builds | |
with: | |
key: ${{ matrix.os }}-${{ matrix.cuda-version }}-torch-${{ matrix.torch-version }}-${{ matrix.cmake-build-type }}-ccache-${{ github.run_id }} | |
restore-keys: ${{ matrix.os }}-${{ matrix.cuda-version }}-torch-${{ matrix.torch-version }}-${{ matrix.cmake-build-type }}-ccache- | |
path: ${{ env.CCACHE_DIR }} | |
- name: Configure and build | |
run: | | |
set -x | |
source .github/workflows/cuda/${{ runner.os }}-env.sh ${{ matrix.cuda-version }} | |
cmake --version | |
mkdir build | |
cd build | |
cmake .. \ | |
-GNinja \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} \ | |
-DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \ | |
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/libtorch \ | |
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \ | |
-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_HOME | |
ninja | |
- name: Clean compiler cache | |
run: | | |
set -x | |
ccache --show-stats | |
ccache --evict-older-than 7d | |
ccache -s | |
ccache --show-stats |