1
3

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 5 years have passed since last update.

nvidia-container-toolkitでKivyを動かした

Last updated at Posted at 2020-04-04

困ったこと

Dockerでnvidia/cudaのイメージを使用して、Kivyを入れたら以下のエラーが出てしまいます。
どうもlibGL関係のエラーっぽいです。
解決策を探していたのですが、nvidiaから提供されているnvidia/cudaglのイメージを使ったほうが楽そうだったので、
それで解決しました。
似たようなエラーがROSで起こった気もするのでこっちのイメージを使うほうがいいかもしれません。

root@:/work/test_kivy# python3 main.py 
[INFO   ] [Logger      ] Record log in /root/.kivy/logs/kivy_20-04-04_4.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/usr/local/lib/python3.5/dist-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [ImageLoaderFFPy] Using ffpyplayer 4.3.1
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_ffpyplayer, img_gif (img_pil ignored)
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
[INFO   ] [Window      ] Provider: x11(['window_egl_rpi', 'window_sdl2'] ignored)
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

Dockerfile

kivyのインストールを含めたDockerfileをメモとして残して起きます。

Dockerfile
FROM nvidia/cudagl:10.1-devel-ubuntu16.04

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

# ここは自分の好きなツールを入れています
RUN apt-get update && apt-get -y upgrade && apt-get install -y wget unzip tree git vim byobu && \
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN apt-get update && apt-get install -y build-essential zlib1g-dev libssl-dev libffi-dev &&\
    apt-get install -y build-essential checkinstall libreadline-gplv2-dev && \
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN apt-get update && apt-get install -y libncursesw5-dev libssl-dev libsqlite3-dev &&\
    apt-get install -y tk-dev libgdbm-dev libc6-dev libbz2-dev mesa-utils libgl1-mesa-glx cmake &&\
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN apt-get update && apt-get install -y libsdl2-dev &&\
    rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN mkdir /workspace
RUN cd /workspace && wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz &&\
    tar zxvf Python-3.7.3.tgz &&\
    cd  /workspace/Python-3.7.3 &&\
    ./configure --enable-optimizations --enable-shared CFLAGS=-fPIC &&\
    make -j8 && make install && ldconfig
RUN python3 -m pip install kivy
RUN python3 -m pip install kivy_examples
RUN python3 -m pip install ffpyplayer
WORKDIR /workspace
RUN rm Python-3.7.3.tgz

build & run

$ docker build . -t kivy_test:latest
$ xhost +
$ docker run -it --gpus all --net host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix  kivy_test:latest

あとは、Tutorials(翻訳済み) » Pong Game Tutorial(翻訳済み)に載っているサンプルを動かして動作確認しました。
cupy,chainer(GPU)が動くことはサンプルで確認しました。

参考サイト

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?