From a3f551a63491edfab4cdca4d2526289412d16272 Mon Sep 17 00:00:00 2001 From: Pengfei Xuan Date: Fri, 1 Mar 2024 00:16:47 -0500 Subject: [PATCH] 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