I want to install Pyrender with headless rendering on Ubuntu 14.04. Specifically, I'd like have it installed within a Dockerfile. How can I do it so that OSMesa (and everything else) installs correctly?
Here are the lines from my Dockerfile that got things working (Ubuntu 14.04, python 3.6). It mostly involves following the installation guide , with some extra stuff to make sure deps get installed properly ( llvm-6.0
is the main thing that's tricky).
If you're not trying to run in Docker, you can basically just run this stuff (in order) from the command line.
# Install pyrender
RUN pip3 install pyrender
# Copy and rename an apt lib file so that apt-add-repository
# works (cleaner way would be to symlink it but Dockerfiles don't seem
# to like symlinks). Might be due to some screwy python3.6/3.4 conflicts
# on my Docker image
RUN cp /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so
# Add new apt repositories and then apt-add some OSMesa deps
RUN add-apt-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main"
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt-get update && apt-get install --yes llvm-6.0 freeglut3 freeglut3-dev pkg-config
# Download OSMesa, then build and install it
RUN curl -o mesa-18.3.3.tar.gz ftp://ftp.freedesktop.org/pub/mesa/mesa-18.3.3.tar.gz
RUN tar xfv mesa-18.3.3.tar.gz
WORKDIR ./mesa-18.3.3
RUN ./configure --prefix=/usr/local \
--enable-opengl --disable-gles1 --disable-gles2 \
--disable-va --disable-xvmc --disable-vdpau \
--enable-shared-glapi \
--disable-texture-float \
--enable-gallium-llvm --enable-llvm-shared-libs \
--with-gallium-drivers=swrast,swr \
--disable-dri --with-dri-drivers= \
--disable-egl --with-egl-platforms= --disable-gbm \
--disable-glx \
--disable-osmesa --enable-gallium-osmesa \
ac_cv_path_LLVM_CONFIG=llvm-config-6.0
RUN make -j8
RUN make install
# Add some new environment variables so the OSMesa libs can be found
ENV MESA_HOME /usr/local
ENV LIBRARY_PATH $LIBRARY_PATH:$MESA_HOME/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$MESA_HOME/lib
ENV C_INCLUDE_PATH $C_INCLUDE_PATH:$MESA_HOME/include/
ENV CPLUS_INCLUDE_PATH $CPLUS_INCLUDE_PATH:$MESA_HOME/include/
# Get rid of the crappy old version of pyopengl, install a sweet new one
RUN pip3 uninstall -y pyopengl
RUN pip3 install git+https://github.com/mmatl/pyopengl.git
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.