Skip to content

Commit

Permalink
Merge pull request #30 from pfxuan/docker-build
Browse files Browse the repository at this point in the history
Add Docker build
  • Loading branch information
pierotofy committed Mar 1, 2024
2 parents 43753aa + aabb715 commit 04ed7fb
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: OpenSplat (Docker)

on:
push:
branches:
- main
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.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
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build Docker Image
uses: docker/build-push-action@v5
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
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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%%.*}"$(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%%.*}"$(echo $CUDA_VERSION | cut -d'.' -f2) && \
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]
Expand Down

0 comments on commit 04ed7fb

Please sign in to comment.