Docker GPU Compatibility Inquiry

I’ve been working on optimizing my applications within Docker containers and have encountered a challenge with GPU access.

Previously, I successfully utilized NVIDIA GPUs with Docker to enhance processing speed. However, when attempting to extend this approach to other GPUs, I faced limitations.

Specifically, on the Raspberry Pi 4, leveraging OpenCL for its Broadcom VideoCore VI GPU appears impractical. On the NVIDIA Jetson Nano, equipped with NVIDIA Maxwell architecture and CUDA cores, GPU utilization is achievable.

Now, concerning Rock Pi with its Mali T860MP4 GPU which is supported by OpenCL, running applications seamlessly on both CPU and GPU outside the Docker container works well. However, when executing the same applications within the container, GPU access seems restricted, and they exclusively run on the CPU.

I’m curious to know if Docker supports GPUs beyond NVIDIA. Your insights on this matter would be greatly appreciated.

As far as I know, it is not Docker that supports NVIDIA GPUs, but NVIDIA created a container runtime and the NVIDIA container toolkit to support their GPUs in a special, isolated environment.

You will find the same with LXC containers:

Any GPU vendor could do the same. You can read about ROCm too which is for AMD GPUs:

I haven’t done a full research on GPU support for containers. I usually found the same as you, mentioning NVIDIA only. There is also GPU supports in Docker Desktop on Windows, which works because WSL2 supports NVIDIA GPUs.

But that is probably because NVIDIA makes it possible to support GPUs.

I successfully created a Docker container based on the Ubuntu image, installed CUDA drivers, and integrated OpenCV with CUDA support. When running this container on the NVIDIA Jetson Nano, adding the --gpus command worked seamlessly, allowing access to the GPU.

However, when following a similar process for OpenCL—installing OpenCL drivers, integrating OpenCV with OpenCL support, and running the Docker container with the --gpus command—I faced challenges on the Rock Pi. Despite these efforts, the container did not access the Rock Pi’s GPU.

This leads me to inquire: Does Docker Container exclusively support NVIDIA GPUs, or are there additional considerations for GPUs ?