Skip to content

Commit

Permalink
Merge pull request #466 from alicevision/dev_docker2
Browse files Browse the repository at this point in the history
[Docker] New docker support
  • Loading branch information
fabiencastan authored Aug 8, 2018
2 parents 1134635 + 108f34d commit 996dda5
Show file tree
Hide file tree
Showing 11 changed files with 881 additions and 108 deletions.
151 changes: 89 additions & 62 deletions CMakeLists.txt

Large diffs are not rendered by default.

91 changes: 58 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
FROM ubuntu:14.04

# Add openMVG binaries to path
ENV PATH $PATH:/opt/openMVG_Build/install/bin

# Get dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
graphviz \
git \
gcc-4.8 \
gcc-4.8-multilib \
libpng-dev \
libjpeg-dev \
libtiff-dev \
libxxf86vm1 \
libxxf86vm-dev \
libxi-dev \
libxrandr-dev \
python-dev \
python-pip

# Clone the openvMVG repo
ADD . /opt/openMVG
RUN cd /opt/openMVG && git submodule update --init --recursive

# Build
RUN mkdir /opt/openMVG_Build && cd /opt/openMVG_Build && cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX="/opt/openMVG_Build/install" -DOpenMVG_BUILD_TESTS=ON \
-DOpenMVG_BUILD_EXAMPLES=ON . ../openMVG/src/ && make

RUN cd /opt/openMVG_Build && make test
ARG CUDA_TAG=7.0
ARG OS_TAG=7
ARG NPROC=1
FROM nvidia/cuda:${CUDA_TAG}-devel-centos${OS_TAG}
LABEL maintainer="AliceVision Team [email protected]"

# use CUDA_TAG to select the image version to use
# see https://hub.docker.com/r/nvidia/cuda/
#
# CUDA_TAG=8.0-devel
# docker build --build-arg CUDA_TAG=$CUDA_TAG --tag alicevision:$CUDA_TAG .
#
# then execute with nvidia docker (https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0))
# docker run -it --runtime=nvidia alicevision


# OS/Version (FILE): cat /etc/issue.net
# Cuda version (ENV): $CUDA_VERSION

# Install all compilation tools
# - file and openssl are needed for cmake
RUN yum -y install \
file \
build-essential \
make \
git \
wget \
unzip \
yasm \
pkg-config \
libtool \
nasm \
automake \
openssl-devel \
gcc-gfortran

# Manually install cmake 3.11
WORKDIR /opt
RUN wget https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz && tar zxvf cmake-3.11.0.tar.gz && cd cmake-3.11.0 && ./bootstrap --prefix=/usr/local -- -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON && make -j8 && make install

ENV AV_DEV=/opt/AliceVision_git \
AV_BUILD=/tmp/AliceVision_build \
AV_INSTALL=/opt/AliceVision_install \
AV_BUNDLE=/opt/AliceVision_bundle \
PATH="${PATH}:${AV_BUNDLE}"

COPY . "${AV_DEV}"

WORKDIR "${AV_BUILD}"
RUN cmake "${AV_DEV}" -DCMAKE_BUILD_TYPE=Release -DALICEVISION_BUILD_DEPENDENCIES:BOOL=ON -DINSTALL_DEPS_BUILD:BOOL=ON -DCMAKE_INSTALL_PREFIX="${AV_INSTALL}" -DALICEVISION_BUNDLE_PREFIX="${AV_BUNDLE}"

WORKDIR "${AV_BUILD}"
RUN make -j${NPROC} install && make bundle
# && cd /opt && rm -rf "${AV_BUILD}"

WORKDIR "${AV_BUNDLE}/share/aliceVision"
RUN wget https://gitlab.com/alicevision/trainedVocabularyTreeData/raw/master/vlfeat_K80L3.SIFT.tree

65 changes: 65 additions & 0 deletions Dockerfile_ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARG CUDA_TAG=9.2
ARG OS_TAG=18.04
ARG NPROC=1
FROM nvidia/cuda:${CUDA_TAG}-devel-ubuntu${OS_TAG}
LABEL maintainer="AliceVision Team [email protected]"

# use CUDA_TAG to select the image version to use
# see https://hub.docker.com/r/nvidia/cuda/
#
# CUDA_TAG=8.0-devel
# docker build --build-arg CUDA_TAG=$CUDA_TAG --tag alicevision:$CUDA_TAG .
#
# then execute with nvidia docker (https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0))
# docker run -it --runtime=nvidia alicevision


# OS/Version (FILE): cat /etc/issue.net
# Cuda version (ENV): $CUDA_VERSION

# Install all compilation tools
RUN apt-get clean && \
apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libtool \
nasm \
automake \
gfortran

# rm -rf /var/lib/apt/lists/*

ENV AV_DEV=/opt/AliceVision_git \
AV_BUILD=/tmp/AliceVision_build \
AV_INSTALL=/opt/AliceVision_install \
AV_BUNDLE=/opt/AliceVision_bundle \
PATH="${PATH}:${AV_BUNDLE}"

COPY . "${AV_DEV}"


# Cannot get rig of this error on lapack build on Ubuntu, so use system libraries for lapack/suitesparse:
#CMake Error at BLAS/SRC/cmake_install.cmake:53 (file):
# file INSTALL cannot find
# "/tmp/AliceVision_build/external/lapack_build/lib/libblas.so.3.8.0".
#Call Stack (most recent call first):
# BLAS/cmake_install.cmake:46 (include)
# cmake_install.cmake:72 (include)
RUN apt-get install -y --no-install-recommends liblapack-dev libsuitesparse-dev

WORKDIR "${AV_BUILD}"
RUN cmake "${AV_DEV}" -DCMAKE_BUILD_TYPE=Release -DALICEVISION_BUILD_DEPENDENCIES:BOOL=ON -DAV_BUILD_LAPACK:BOOL=OFF -DAV_BUILD_SUITESPARSE:BOOL=OFF -DCMAKE_INSTALL_PREFIX="${AV_INSTALL}" -DALICEVISION_BUNDLE_PREFIX="${AV_BUNDLE}"

WORKDIR "${AV_BUILD}"
RUN make -j${NPROC} install && make bundle
# && cd /opt && rm -rf "${AV_BUILD}"

WORKDIR "${AV_BUNDLE}/share/aliceVision"
RUN wget https://gitlab.com/alicevision/trainedVocabularyTreeData/raw/master/vlfeat_K80L3.SIFT.tree

32 changes: 32 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,35 @@ target_link_libraries(main ${ALICEVISION_LIBRARIES})
Specify to CMake where AliceVision is installed by using the `AliceVision_DIR` cmake variable: `-DAliceVision_DIR:STRING="YourInstallPath"/share/aliceVision/cmake`


### Docker image

A docker image can be built using the CentOS 7 or Ubuntu 18 Dockerfiles.
The Dockerfiles are based on `nvidia/cuda` images (https://hub.docker.com/r/nvidia/cuda/)

```
docker build --tag alicevision:centos7-cuda7.0 .
docker build --tag alicevision:ubuntu18.04-cuda9.2 -f Dockerfile_ubuntu .
```

Parameters `OS_TAG` and `CUDA_TAG` can be passed to build the image with a specific OS and CUDA version.
Use NPROC=8 to select the number of cores to use, 1 by default.
For example, in order to create a CentOS 7 with Cuda 9.2, use:

```
docker build --build-arg OS_TAG=7 CUDA_TAG=9.2 --tag alicevision:centos7-cuda9.2 .
docker build --build-arg OS_TAG=16.04 CUDA_TAG=8.0 NPROC=8 --tag alicevision:ubuntu16.04-cuda8.0 -f Dockerfile_ubuntu .
```

In order to run the image [nvidia docker](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)) is needed.

```
docker run -it --runtime=nvidia alicevision:centos7-cuda9.2
```

To retrieve the generated files:

```
# Create an instance of the image, copy the files and remove the temporary docker instance.
CID=$(docker create alicevision:centos7-cuda9.2) && docker cp ${CID}:/opt/AliceVision_install . && docker cp ${CID}:/opt/AliceVision_bundle . && docker rm ${CID}
```

17 changes: 14 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,17 @@ if(ALICEVISION_BUILD_SFM)
if(Ceres_FOUND)
message(STATUS "Ceres include dirs ${CERES_INCLUDE_DIRS}")
message(STATUS "Ceres libraries ${CERES_LIBRARIES}")
if(ALICEVISION_REQUIRE_CERES_WITH_SUITESPARSE)
# Ceres export include dirs but doesn't export suitesparse lib dependencies in CeresConfig.cmake
# So here is a workaround:
find_package(SuiteSparse)
message(STATUS "SUITESPARSE_LIBRARIES: ${SUITESPARSE_LIBRARIES}")
if(SUITESPARSE_LIBRARIES)
list(APPEND CERES_LIBRARIES ${SUITESPARSE_LIBRARIES})
endif()
endif()
message(STATUS "CERES_LIBRARIES: ${CERES_LIBRARIES}")
message(STATUS "CERES_INCLUDE_DIRS: ${CERES_INCLUDE_DIRS}")
if(WIN32)
# avoid 'ERROR' macro clashing on Windows
add_definitions(-DGLOG_NO_ABBREVIATED_SEVERITIES)
Expand Down Expand Up @@ -899,7 +910,7 @@ add_subdirectory(software)
# ==============================================================================

install(EXPORT aliceVision-targets
DESTINATION share/aliceVision/cmake FILE AliceVisionTargets.cmake)
DESTINATION ${CMAKE_INSTALL_DATADIR}/aliceVision/cmake FILE AliceVisionTargets.cmake)

#Adapt build include paths to install path
set(ALICEVISION_INCLUDE_DIRS
Expand Down Expand Up @@ -928,7 +939,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AliceVisionConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/AliceVisionConfig.cmake" @ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AliceVisionConfig.cmake"
DESTINATION share/aliceVision/cmake)
DESTINATION ${CMAKE_INSTALL_DATADIR}/aliceVision/cmake)

# create the config.hpp file containing all the preprocessor definitions
set(configfile "${generatedDir}/aliceVision/config.hpp")
Expand All @@ -937,7 +948,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.hpp.in"


install(FILES "${configfile}"
DESTINATION "include/aliceVision")
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aliceVision")

# Add uninstall target
configure_file(
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif()

install(
DIRECTORY .
DESTINATION include/aliceVision
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aliceVision
COMPONENT headers
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h" PATTERN "*.tcc"
)
Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/sensorDB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ alicevision_add_library(aliceVision_sensorDB
${Boost_INCLUDE_DIRS}
)

# Install sensor_width_camera_database.txt
install(FILES sensor_width_camera_database.txt
DESTINATION share/aliceVision
# Install DB
install(FILES cameraSensors.db
DESTINATION ${CMAKE_INSTALL_DATADIR}/aliceVision
)

# Unit tests
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/aliceVision/sensorDB/parseDatabase_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using namespace aliceVision::sensorDB;
namespace fs = boost::filesystem;

static const std::string sDatabase = (fs::path(THIS_SOURCE_DIR) / "sensor_width_camera_database.txt").string();
static const std::string sDatabase = (fs::path(THIS_SOURCE_DIR) / "cameraSensors.db").string();

BOOST_AUTO_TEST_CASE(InvalidDatabase)
{
Expand Down
Loading

0 comments on commit 996dda5

Please sign in to comment.