我想在Ubuntu 14.04上安装带有headless rendering的Pyrender。具体来说,我希望将其安装在Dockerfile中。如何才能正确安装OSMesa (以及其他所有内容)?
发布于 2019-07-16 05:12:51
下面是我的Dockerfile (Ubuntu 14.04,python 3.6)中的几行代码。它主要涉及遵循installation guide,以及一些额外的东西,以确保deps正确安装(llvm-6.0是最棘手的事情)。
如果你不想在Docker中运行,你基本上可以从命令行(按顺序)运行这些东西。
# 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.githttps://stackoverflow.com/questions/57047269
复制相似问题