I have a fresh Ubuntu 16.04 installation, with only the AMDGPU-Pro (proprietary) driver installed and docker-engine (from the apt.dockerproject.org PPA).
I want to run OpenCL programs inside Docker containers. I figure: the kernel is shared, so the GPU module(s) should be available for the containers, what is missing is the libs to access the module(s).
I set up a container and compiled an OpenCL program inside it. Running the program inside it returns that no devices were found. So I copied the binary to the host, and executing the binary there works (both my GPU devices were detected).
I attempted to create a fresh container (from Ubuntu:16.04) and copied the binary, and all libs it required from the container used for compilation, AND the folder /usr/lib/x86_64-linux-gnu/amdgpu-pro
from the host.
Unfortunately, this also didn't work. What could I be missing?
Best Answer
Managed to get it to work. Summary:
Here's an example script to build the docker image: https://gist.github.com/anonymous/fea9c0a9e986eeda7cf58e47f47c89f2
And here's an example command to run a container with the created image:
In case anyone stumbles into a similar problem, I'll also list how I found out the "solution":
strace ./cltest &> host.strace
docker run --rm --security-opt seccomp:unconfined -v $(pwd):/external climage strace /external/cltest &> ./container.strace
vimdiff
vimdiff container.strace host.strace