Convert gsplat cuda code to hip #14
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 HIP) | |
on: | |
push: | |
branches: | |
- hip-build | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened ] | |
release: | |
types: [ published, edited ] | |
jobs: | |
build: | |
name: ${{ matrix.os }}-rocm-${{ matrix.rocm-version }}-torch-${{ matrix.torch-version }}-${{ matrix.cmake-build-type }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04] # [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04] | |
arch: [x64] # [x64, x86] | |
torch-version: [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: [11.8.0] # [12.3.1, 12.1.1, 11.8.0, 11.7.1, 11.6.2, 11.5.2,11.4.4, 11.3.1, 11.2.2, 11.1.1, 11.0.3, cpu] | |
rocm-version: [5.7.3] # [5.4.2, 5.6.1, 5.7.3, 6.0.1, 6.0.2] | |
cmake-build-type: [Release] # [Debug, ClangTidy] | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/ccache | |
CCACHE_BASEDIR: ${{ github.workspace }} | |
CL: /MP | |
CMAKE_GENERATOR: Ninja | |
CMAKE_GENERATOR_PLATFORM: ${{matrix.arch}} | |
TORCH_ROCM_ARCH_LIST: '7.0;7.5' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Free disk space | |
run: | | |
df -h | |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc || true | |
df -h | |
- name: Setup Ubuntu | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
build-essential \ | |
cmake \ | |
ninja-build \ | |
libopencv-dev \ | |
clang lldb lld \ | |
wget | |
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: Sudo Tar Wrapper | |
run: | | |
# Workaround: https://github.com/containers/podman/discussions/17868 | |
sudo mv -fv /usr/bin/tar /usr/bin/tar.orig | |
echo -e '#!/bin/sh\n\nsudo /usr/bin/tar.orig "$@"' | sudo tee -a /usr/bin/tar | |
sudo chmod +x /usr/bin/tar | |
- name: Restore CUDA Cache | |
uses: actions/cache@v4 | |
id: cuda-cache | |
with: | |
key: cuda-${{matrix.CUDA-VERSION}}-ubuntu | |
path: | | |
/usr/local/cuda* | |
- name: Install CUDA | |
if: ${{ steps.cuda-cache.outputs.cache-hit != 'true' }} | |
run: | | |
bash .github/workflows/cuda/${{ runner.os }}.sh ${{ matrix.cuda-version }} | |
- name: Restore ROCm Cache | |
uses: actions/cache@v4 | |
id: rocm-cache | |
with: | |
key: rocm-${{matrix.ROCM-VERSION}}-ubuntu | |
path: | | |
/opt/rocm* | |
/etc/alternatives/rocm | |
- name: Install ROCm | |
if: ${{ steps.rocm-cache.outputs.cache-hit != 'true' }} | |
run: | | |
bash .github/workflows/rocm/${{ runner.os }}.sh ${{ matrix.rocm-version }} ${{ matrix.os }} | |
- name: Setup ROCm And CUDA | |
shell: bash | |
run: | | |
ROCM_VER_FULL=${{ matrix.rocm-version }} | |
ROCM_VER_ARR=($(echo ${ROCM_VER_FULL} | tr "." " ")) | |
ROCM_VER="${ROCM_VER_ARR[0]}.${ROCM_VER_ARR[1]}" | |
ROCM_VER_ID="${ROCM_VER_ARR[0]}_${ROCM_VER_ARR[1]}" | |
ROCM_VER_SHORT="rocm${ROCM_VER_ARR[0]}.${ROCM_VER_ARR[1]}" | |
echo "ROCM_VER_SHORT=${ROCM_VER_SHORT}" >> ${GITHUB_ENV} | |
CUDA_VER_FULL=${{ matrix.cuda-version }} | |
CUDA_VER_ARR=($(echo ${CUDA_VER_FULL} | tr "." " ")) | |
CUDA_VER="${CUDA_VER_ARR[0]}.${CUDA_VER_ARR[1]}" | |
CUDA_VER_ID="${CUDA_VER_ARR[0]}_${CUDA_VER_ARR[1]}" | |
CUDA_VER_SHORT="cu${CUDA_VER_ARR[0]}${CUDA_VER_ARR[1]}" | |
echo "CUDA_VER_SHORT=${CUDA_VER_SHORT}" >> ${GITHUB_ENV} | |
- name: Restore LibTorch Cache | |
uses: actions/cache@v4 | |
id: libtorch-cache | |
with: | |
key: libtorch-${{ matrix.torch-version }}-${{env.ROCM_VER_SHORT}}-ubuntu | |
path: | | |
/mnt/deps/libtorch | |
- name: Install LibTorch | |
if: ${{ steps.libtorch-cache.outputs.cache-hit != 'true' }} | |
run: | | |
sudo mkdir -p -m 777 /mnt/deps | |
wget --no-check-certificate -nv https://download.pytorch.org/libtorch/${ROCM_VER_SHORT}/libtorch-cxx11-abi-shared-with-deps-${{ matrix.torch-version }}%2B${ROCM_VER_SHORT}.zip -O /mnt/deps/libtorch.zip | |
unzip -q /mnt/deps/libtorch.zip -d /mnt/deps | |
rm /mnt/deps/libtorch.zip | |
- name: Cache Build | |
uses: actions/cache@v4 | |
id: cache-builds | |
with: | |
key: ${{ matrix.os }}-rocm-${{ matrix.rocm-version }}-torch-${{ matrix.torch-version }}-${{ matrix.cmake-build-type }}-ccache-${{ github.run_id }} | |
restore-keys: ${{ matrix.os }}-rocm-${{ matrix.rocm-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 ${CUDA_VER_SHORT} | |
export PATH=$PATH:/opt/rocm/bin | |
clang --version | |
hipify-clang ./vendor/gsplat/backward.cu ./vendor/gsplat/bindings.cu ./vendor/gsplat/forward.cu --cuda-path=${CUDA_HOME} --print-stats -- -std=c++15 | |
- name: Clean Compiler Cache | |
run: | | |
set -x | |
ccache --show-stats | |
ccache --evict-older-than 7d | |
ccache -s | |
ccache --show-stats |