From a3f551a63491edfab4cdca4d2526289412d16272 Mon Sep 17 00:00:00 2001 From: Pengfei Xuan Date: Fri, 1 Mar 2024 00:16:47 -0500 Subject: [PATCH 1/3] Add Dockerfile --- .github/workflows/docker.yml | 36 +++++++++++++++++++++++ Dockerfile | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..bac5bbd --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,36 @@ +name: OpenSplat (Docker) + +on: + push: + branches: + - docker-build + pull_request: + types: [ assigned, opened, synchronize, reopened ] + release: + types: [ published, edited ] + +jobs: + build: + name: ${{ matrix.os }}-cuda-${{ 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-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: [12.1.1] # [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] + cmake-build-type: [Release] # [Debug, ClangTidy] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build Docker Image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: false + tags: opensplat:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1e0527c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +ARG UBUNTU_VERSION=22.04 + +FROM ubuntu:${UBUNTU_VERSION} + +ARG TORCH_VERSION=2.2.1 +ARG CUDA_VERSION=12.1.1 +ARG TORCH_CUDA_ARCH_LIST=7.0;7.5 +ARG CMAKE_BUILD_TYPE=Release + +SHELL ["/bin/bash", "-c"] + +# Env variables +ENV DEBIAN_FRONTEND noninteractive + +# Prepare directories +WORKDIR /code + +# Copy everything +COPY . ./ + +# Install build dependencies +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + cmake \ + ninja-build \ + libopencv-dev \ + unzip \ + wget \ + sudo && \ + apt-get autoremove -y --purge && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + + +# Install CUDA +RUN bash .github/workflows/cuda/Linux.sh ${CUDA_VERSION} + +# Install libtorch +RUN wget --no-check-certificate -nv https://download.pytorch.org/libtorch/cu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}"/libtorch-cxx11-abi-shared-with-deps-${TORCH_VERSION}%2Bcu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}".zip -O libtorch.zip && \ + unzip -q libtorch.zip -d . && \ + rm ./libtorch.zip + +# Configure and build \ +RUN source .github/workflows/cuda/Linux-env.sh cu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}" && \ + mkdir build && \ + cd build && \ + cmake .. \ + -GNinja \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ + -DCMAKE_PREFIX_PATH=/code/libtorch \ + -DCMAKE_INSTALL_PREFIX=/code/install \ + -DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}" \ + -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME} && \ + ninja \ No newline at end of file From 49bad6be56d819708aed4a9270d704775f5b05c8 Mon Sep 17 00:00:00 2001 From: Pengfei Xuan Date: Fri, 1 Mar 2024 09:52:53 -0500 Subject: [PATCH 2/3] Perform full test (docker) --- .github/workflows/docker.yml | 8 ++++++-- Dockerfile | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bac5bbd..087372e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,8 +18,8 @@ jobs: 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: [12.1.1] # [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] + 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: [11.8.0, 12.1.1] # [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] cmake-build-type: [Release] # [Debug, ClangTidy] steps: - name: Checkout Repository @@ -32,5 +32,9 @@ jobs: with: context: . file: ./Dockerfile + build-args: | + CUDA_VERSION=${{ matrix.cuda-version }} + TORCH_VERSION=${{ matrix.torch-version }} + CMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} push: false tags: opensplat:latest diff --git a/Dockerfile b/Dockerfile index 1e0527c..6e60974 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,12 +37,12 @@ RUN apt-get update && \ RUN bash .github/workflows/cuda/Linux.sh ${CUDA_VERSION} # Install libtorch -RUN wget --no-check-certificate -nv https://download.pytorch.org/libtorch/cu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}"/libtorch-cxx11-abi-shared-with-deps-${TORCH_VERSION}%2Bcu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}".zip -O libtorch.zip && \ +RUN wget --no-check-certificate -nv https://download.pytorch.org/libtorch/cu"${CUDA_VERSION%%.*}"$(echo $CUDA_VERSION | cut -d'.' -f2)/libtorch-cxx11-abi-shared-with-deps-${TORCH_VERSION}%2Bcu"${CUDA_VERSION%%.*}"$(echo $CUDA_VERSION | cut -d'.' -f2).zip -O libtorch.zip && \ unzip -q libtorch.zip -d . && \ rm ./libtorch.zip # Configure and build \ -RUN source .github/workflows/cuda/Linux-env.sh cu"${CUDA_VERSION%%.*}${CUDA_VERSION##*.}" && \ +RUN source .github/workflows/cuda/Linux-env.sh cu"${CUDA_VERSION%%.*}"$(echo $CUDA_VERSION | cut -d'.' -f2) && \ mkdir build && \ cd build && \ cmake .. \ From aabb7152b268af6b01204aa1581e908c126818c1 Mon Sep 17 00:00:00 2001 From: Pengfei Xuan Date: Fri, 1 Mar 2024 11:13:19 -0500 Subject: [PATCH 3/3] Add docker build readme and switch ci tigger back to the main branch --- .github/workflows/docker.yml | 2 +- README.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 087372e..10fd510 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: OpenSplat (Docker) on: push: branches: - - docker-build + - main pull_request: types: [ assigned, opened, synchronize, reopened ] release: diff --git a/README.md b/README.md index 30be215..2397417 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,25 @@ Requirements: The software has been tested on Ubuntu 20.04 and Windows. With some changes it could run on macOS (help us by opening a PR?). +## Build Docker Image +Navigate to the root directory of OpenSplat repo that has Dockerfile and run the following command to build the Docker image: +```bash +docker build -t opensplat . +``` + +The `-t` flag and other `--build-arg` let you tag and further customize your image across different ubuntu versions, CUDA/libtorch stacks, and hardware accelerators. +For example, to build an image with Ubuntu 22.04, CUDA 12.1.1, libtorch 2.2.1, and support for CUDA architectures 7.0 and 7.5, run the following command: + +```bash +docker build \ + -t opensplat:ubuntu-22.04-cuda-12.1.1-torch-2.2.1 \ + --build-arg UBUNTU_VERSION=22.04 \ + --build-arg CUDA_VERSION=12.1.1 \ + --build-arg TORCH_VERSION=2.2.1 \ + --build-arg TORCH_CUDA_ARCH_LIST="7.0;7.5" \ + --build-arg CMAKE_BUILD_TYPE=Release . +``` + ## Run To get started, download a dataset and extract it to a folder: [ [banana](https://drive.google.com/file/d/1mUUZFDo2swd6CE5vwPPkjN63Hyf4XyEv/view?usp=sharing) ] [ [train](https://drive.google.com/file/d/1-X741ecDczTRoMc3YenJLSFC9ulWXeNc/view?usp=sharing) ] [ [truck](https://drive.google.com/file/d/1WWXo-GKo6d-yf-K1T1CswIdkdZrBNZ_e/view?usp=sharing) ]