Compiling Pixar's USD in a Docker container for Azure Functions

501 views Asked by At

Has anyone tried compiling Pixar's USD in the official Docker images for Azure Functions? I've been trying the following Dockerfile (inspired by https://github.com/leon/docker-gltf-to-udsz/blob/master/usd/Dockerfile):

FROM mcr.microsoft.com/azure-functions/node:2.0

RUN apt-get -qq update && apt-get install -y --no-install-recommends \
    git build-essential cmake nasm python2.7-dev python-pip python-jinja2 \
    libglew-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev zlib1g-dev && \
    rm -rf /var/lib/apt/lists/*

ENV USD_RELEASE="19.11"
ENV USD_SRC="/usr/src/usd"
ENV USD_INSTALL="/usr/local/usd"
ENV PYTHONPATH="${PYTHONPATH}:${USD_INSTALL}/lib/python"
ENV PATH="${PATH}:${USD_INSTALL}/bin"
RUN git clone --branch "v${USD_RELEASE}" --depth 1 https://github.com/PixarAnimationStudios/USD.git "${USD_SRC}"
RUN cd "${USD_SRC}" && \
    python ./build_scripts/build_usd.py -v --no-usdview "${USD_INSTALL}" && \
    rm -rf "${USD_SRC}" "${USD_INSTALL}/build" "${USD_INSTALL}/src"

But at 52% the build fails with this message:

...
[ 52%] Building CXX object pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4f.cpp.o
[ 52%] Building CXX object pxr/base/lib/work/CMakeFiles/work.dir/threadLimits.cpp.o
[ 52%] Building CXX object pxr/base/lib/work/CMakeFiles/work.dir/utils.cpp.o
[ 52%] Linking CXX shared library libwork.so
[ 52%] Built target work
[ 52%] Building CXX object pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4d.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
pxr/base/lib/tf/CMakeFiles/_tf.dir/build.make:782: recipe for target 'pxr/base/lib/tf/CMakeFiles/_tf.dir/wrapTestTfPython.cpp.o' failed
make[2]: *** [pxr/base/lib/tf/CMakeFiles/_tf.dir/wrapTestTfPython.cpp.o] Error 4
CMakeFiles/Makefile2:507: recipe for target 'pxr/base/lib/tf/CMakeFiles/_tf.dir/all' failed
make[1]: *** [pxr/base/lib/tf/CMakeFiles/_tf.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/functions.cpp.o
[ 52%] Building CXX object pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMultiInterval.cpp.o
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/hash.cpp.o
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/streamOut.cpp.o
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/types.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
pxr/base/lib/gf/CMakeFiles/_gf.dir/build.make:446: recipe for target 'pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4f.cpp.o' failed
make[2]: *** [pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4f.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/value.cpp.o
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/arrayPyBuffer.cpp.o
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/valueFromPython.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.
pxr/base/lib/gf/CMakeFiles/_gf.dir/build.make:470: recipe for target 'pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4d.cpp.o' failed
make[2]: *** [pxr/base/lib/gf/CMakeFiles/_gf.dir/wrapMatrix4d.cpp.o] Error 4
[ 52%] Building CXX object pxr/base/lib/vt/CMakeFiles/vt.dir/wrapArray.cpp.o
CMakeFiles/Makefile2:672: recipe for target 'pxr/base/lib/gf/CMakeFiles/_gf.dir/all' failed
make[1]: *** [pxr/base/lib/gf/CMakeFiles/_gf.dir/all] Error 2
[ 52%] Linking CXX shared library libvt.so
[ 52%] Built target vt
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I'm not sure what to make of it as I'm not well-versed in C++ development... Any ideas what could be wrong here? Perhaps some missing dependencies?

2

There are 2 answers

0
Jacob On

I had this same issue when I was building, and the fix was to increase my Docker's memory limit. Apparently, the cc1plus error is almost always due to a lack of memory.

0
L.Lauenburg On

Quick Answer: Docker has to litte memory available -> go here to fix it.

I just run into the same problem while executing catkin_make to build CubeSLAM within a docker-ubuntu-vnc-desktop container.

As dtzman already mentioned - and explained more thoroughly in this StackOverflow post by Jon - it has to do with too little memory.

If you're not running on Linux, where docker has access to the whole memory of the host machine, you can easily manage the resources available to docker by following Roberts answer to the (not quite correctly phrased) StackOverflow question 'How to assign more memory to docker container'.