isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.33k stars 2.29k forks source link

Reduce docker image size #256

Closed takanokage closed 6 years ago

takanokage commented 6 years ago

My current implementation is about 3.8GB:

The above options do take a lot of space. A previous implementation used less than 1.5GB with some more or less obvious caveats.

Caveats of the second approach:

takanokage commented 6 years ago

I have looked into using Alpine as the base of an Open3D Docker image and made the following notes:

  1. It can lead to really small image sizes, mainly because Alpine is such a small distribution.
  2. The setup becomes very complicated very quickly. Some Open3D dependencies are listed in the alpine:latest or specific alpine:x.xv repositories other in the alpine:edge, some packages are under testing only while others have stable releases. An Alpine based image will take significantly more development effort than the Ubuntu based image I've implemented.
takanokage commented 6 years ago

An idea is to look into providing the option to perform headless from the terminal only with no support for vnc/window management/interactive GUI. This has the potential of keeping the image super light-weight.

syncle commented 6 years ago

This issue is related to #262.

syncle commented 6 years ago

Closing this issue as #262 is closed for now.

plusk01 commented 3 years ago

Just to add an update: I attempted to build open3d using the python:3.9-alpine3.13 base docker image - I made some progress, but as @takanokage suggested it got pretty complicated and I had to move on. Maybe this will be useful for the next attempt

FROM python:3.9-alpine3.13

RUN apk update && apk upgrade && \
    apk add --update --no-cache \
        build-base \
        cmake \
        eigen-dev \
        git

RUN cd /tmp && \
    git clone -b rspd --recurse-submodules https://github.com/plusk01/Open3D && \
    mkdir Open3D/build
    # mkdir Open3D/build && cd Open3D/build && cmake -DBUILD_EXAMPLES=OFF .. && \
    # make -j$(nproc) && make install-pip-package -j$(nproc)

RUN apk add --update --no-cache \
    libx11-dev \
    xrandr \
    libxrandr-dev \
    glu \
    glu-dev \
    glfw \
    glfw-dev \
    libxcursor-dev \
    clang \
    clang-dev

# the next line breaks, so i would drop into a /bin/sh at the previous successful layer and try things
RUN cd /tmp/Open3D/build && cmake -DBUILD_EXAMPLES=OFF -DBUILD_FILAMENT_FROM_SOURCE=ON .. && make -j$(nproc)

notes:

finally, filament fails with

-- Build files have been written to: /tmp/Open3D/build/filament/src/ext_filament-build
[ 20%] Performing build step for 'ext_filament'
Scanning dependencies of target gtest
[  0%] Building CXX object third_party/libgtest/tnt/CMakeFiles/gtest.dir/__/googletest/src/gtest-all.cc.o
In file included from /tmp/Open3D/build/filament/src/ext_filament/third_party/libgtest/googletest/src/gtest-all.cc:38:
/tmp/Open3D/build/filament/src/ext_filament/third_party/libgtest/tnt/../googletest/include/gtest/gtest.h:55:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 error generated.

i.e., clang's libc++ headers can't be found.

Note that I tried removing NO_DEFAULT_PATH from this line to try and get clang to use libstdc++ instead of the missing libc++ (I also set(CPPABI_LIBRARY "") since g++ doesn't let you specify the ABI [<- not sure if true statement])

Ultimately, this seems like the next roadblock - no full support for clang / libc++ in alpine? Maybe need to build clang from source to get libc++ and libc++abi?