2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker opengl error

Last updated at Posted at 2020-05-03

dockerでGUIは使えるようになったけどopenGL errorが出る...

libGL error:

環境:
ubuntu18
nvidia-docker2
nvidia-driver430.50

ubuntu18の場合

DockerFileを作る

FROM ubuntu:18.04
RUN apt -y update &&\
    apt install -y --no-install-recommends mesa-utils x11-apps
   
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

アクセス権限を付与する

xhost local:

イメージの作成

sudo nvidia-docker build --tag opengl-ubuntu18:test .

コンテナーを走らせる

docker run --runtime=nvidia -it --name="opengl-ubuntu18" --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --privileged opengl-ubuntu18:test

確認

glxgears

成功!
image.png

ubuntu16の場合

FROM ubuntu:16.04
RUN apt -y update &&\
apt install -y --no-install-recommends mesa-utils x11-apps \
    pkg-config \
    libxau-dev \
    libxdmcp-dev \
    libxcb1-dev \
    libxext-dev \
    libx11-dev && \
    rm -rf /var/lib/apt/lists/*
COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
  /usr/local/lib/x86_64-linux-gnu \
  /usr/local/lib/x86_64-linux-gnu

COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
  /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json \
  /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json

RUN echo '/usr/local/lib/x86_64-linux-gnu' >> /etc/ld.so.conf.d/glvnd.conf && \
    ldconfig && \
    echo '/usr/local/$LIB/libGL.so.1' >> /etc/ld.so.preload && \
    echo '/usr/local/$LIB/libEGL.so.1' >> /etc/ld.so.preload

ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

imageを変えたらros:melodic ros:kineticでも出来た!
これが最小限かな?もっと簡単な方法あったら教えてください

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?