Skip to content

Commit

Permalink
Merge pull request #18 from pfxuan/github-actions
Browse files Browse the repository at this point in the history
Add github CI pipeline for ubuntu
  • Loading branch information
pierotofy authored Feb 23, 2024
2 parents 2db5040 + e674153 commit 852f90b
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/cuda/Linux-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Took from https://github.com/pyg-team/pyg-lib/

case ${1} in
cu121)
export CUDA_HOME=/usr/local/cuda-12.1
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu118)
export CUDA_HOME=/usr/local/cuda-11.8
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu117)
export CUDA_HOME=/usr/local/cuda-11.7
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu116)
export CUDA_HOME=/usr/local/cuda-11.6
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu115)
export CUDA_HOME=/usr/local/cuda-11.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu113)
export CUDA_HOME=/usr/local/cuda-11.3
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;8.0;8.6
;;
cu102)
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${CUDA_HOME}/bin:${PATH}
export TORCH_CUDA_ARCH_LIST="7.0;7.5" # 3.5;5.0+PTX;6.0;
;;
*)
;;
esac
70 changes: 70 additions & 0 deletions .github/workflows/cuda/Linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Took from https://github.com/pyg-team/pyg-lib/

OS=ubuntu2004

case ${1} in
cu121)
CUDA=12.1
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-530.30.02-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers
;;
cu118)
CUDA=11.8
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-520.61.05-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers
;;
cu117)
CUDA=11.7
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.1-515.65.01-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.1/local_installers
;;
cu116)
CUDA=11.6
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-510.47.03-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers
;;
cu115)
CUDA=11.5
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.2-495.29.05-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.2/local_installers
;;
cu113)
CUDA=11.3
APT_KEY=${OS}-${CUDA/./-}-local
FILENAME=cuda-repo-${APT_KEY}_${CUDA}.0-465.19.01-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}.0/local_installers
;;
cu102)
CUDA=10.2
APT_KEY=${CUDA/./-}-local-${CUDA}.89-440.33.01
FILENAME=cuda-repo-${OS}-${APT_KEY}_1.0-1_amd64.deb
URL=https://developer.download.nvidia.com/compute/cuda/${CUDA}/Prod/local_installers
;;
*)
echo "Unrecognized CUDA_VERSION=${1}"
exit 1
;;
esac

wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin
sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget -nv ${URL}/${FILENAME}
sudo dpkg -i ${FILENAME}

if [ "${1}" = "cu117" ] || [ "${1}" = "cu118" ] || [ "${1}" = "cu121" ]; then
sudo cp /var/cuda-repo-${APT_KEY}/cuda-*-keyring.gpg /usr/share/keyrings/
else
sudo apt-key add /var/cuda-repo-${APT_KEY}/7fa2af80.pub
fi

sudo apt-get update
sudo apt-get -y install cuda

rm -f ${FILENAME}
94 changes: 94 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: OpenSplat (Ubuntu)

on:
push:
branches:
- main
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] # [1.12.0, 1.13.0, 2.0.0, 2.1.0, 2.1.1, 2.1.2, 2.2.0]
cuda-version: ['cu118', 'cu121'] # ['cpu', 'cu113', 'cu116', 'cu117']
cmake-build-type: [Release] # [Debug, ClangTidy]

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 \
ccache \
cmake \
ninja-build \
libopencv-dev \
wget
- 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 -k 8
- name: Clean compiler cache
run: |
set -x
ccache --show-stats
ccache --evict-older-than 7d
ccache -s
ccache --show-stats

0 comments on commit 852f90b

Please sign in to comment.