如何在Docker容器中运行OpenCL + OpenGL? [英] How to run OpenCL + OpenGL inside a Docker container?

查看:1458
本文介绍了如何在Docker容器中运行OpenCL + OpenGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是在docker容器中运行OpenCL / OpenGL(互操作)应用程序。但是我还没有成功。

The aim is to run an OpenCL/OpenGL (interop) app inside a docker container. But I have not been successful yet.

我有一台装有NVidia显卡的笔记本电脑,所以我想利用NVidia Dockerfiles [1,2

I have laptop with an NVidia graphics card so I thought leveraging on NVidia Dockerfiles [1,2] would be a good starting point.

以下Dockerfile:

The following Dockerfile:

# Dockerfile to run OpenGL app
FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES},display
RUN apt-get update && apt-get install -y --no-install-recommends \
        mesa-utils && \
    rm -rf /var/lib/apt/lists/*

效果很好,我能够运行 glxgears

works quite well, and I was able to run glxgears.

在自己的容器上运行OpenCL也没什么大不了的:

Running OpenCL on its own container was no big deal either:

# Dockerfile to run OpenCL app
FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
        ocl-icd-libopencl1 \
        clinfo && \
    rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/OpenCL/vendors && \
    echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

并且 clinfo 成功显示了有关我的设备的信息。

and clinfo successfully shows information about my device.

最后,我尝试用OpenGL和OpenCL驱动程序创建一个容器:

Finally here's my attempt at creating a container with both OpenGL and OpenCL drivers:

# Dockerfile mixing OpenGL and OpenCL
FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES},display
RUN apt-get update && apt-get install -y --no-install-recommends \
        mesa-utils \
        ocl-icd-libopencl1 \
        clinfo && \
    rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/OpenCL/vendors && \
    echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

现在,尽管 clinfo 仍会打印OpenCL设备信息,但 glxgears 却失败,并出现以下错误:

And now, although clinfo still prints OpenCL device information, glxgears on the other hand fails with the following error:

Error: couldn't get an RGB, Double-buffered visual 

任何想法如何使它起作用?

Any idea how to make this work? Thanks in advance.

  • [1] https://gitlab.com/nvidia/opencl/blob/ubuntu16.04/devel/Dockerfile
  • [2] https://gitlab.com/nvidia/opencl/blob/ubuntu16.04/runtime/Dockerfile

推荐答案

ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

您忘记了功能显示

这篇关于如何在Docker容器中运行OpenCL + OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆