Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
pfxuan committed Mar 1, 2024
1 parent 43753aa commit a3f551a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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
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%%.*}${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

0 comments on commit a3f551a

Please sign in to comment.