-
Notifications
You must be signed in to change notification settings - Fork 379
Hardware acceleration
x11docker allows hardware acceleration for docker containers with option --gpu
. This wiki page gives some insights to allow custom setups without x11docker.
- Note that only two X servers support GPU acceleration:
Xorg
andXwayland
. Others likeXephyr
,nxagent
orXvfb
only support software rendering. - Wayland compositors like
weston
support GPU acceleration even in nested window mode.
If you run with an unprivileged user in container, add him to groups video
and render
to allow access to the files in /dev/dri
:
--group-add video --group-add render
GPU devices on linux are stored in /dev/dri
.
The most simple setup to allow hardware acceleration is to share these device files with docker run option --device /dev/dri
.
This works flawlessly with open source drivers (MESA) on host and in image.
Additionally it can make sense to share /dev/vga_arbiter
, too, as it may be needed for some multimonitor setups. Use docker run option --device /dev/vga_arbiter
.
- Debian and Ubuntu images:
mesa-utils mesa-utils-extra
- CentOS and Fedora images:
glx-utils mesa-dri-drivers
- Alpine and NixOS images:
mesa-demos mesa-dri-ati mesa-dri-intel mesa-dri-nouveau mesa-dri-swrast
- Arch Linux images:
mesa-demos
The free driver for NVIDIA graphics cards is nouveau
. With nouveau
driver follow instructions above, it will work out of the box with MESA setups.
Closed source non-free proprietary nvidia-driver
needs a quite customized and non-portable setup.
For use of x11docker with proprietary nvidia driver look at x11docker wiki: NVIDIA driver.
For a setup without x11docker, you have two possibilities:
- Either follow the instructions from nvidia/nvidia-docker for a setup allowing docker run option
--runtime=nvidia
. You will be bound to base images provided by NVIDIA. - Or install the driver matching your host driver version in image. The image will not be portable anymore.
- To manually build a base image:
- Find out installed driver version in
/proc/driver/nvidia/version
. - Get matching installer from https://http.download.nvidia.com/XFree86/Linux-x86_64/. Install it in image. It also needs
kmod
. - Alternatively try with NVIDIA driver package from image base system if it provides one.
- Find out installed driver version in
To use a custom base image, share all files matching /dev/nvidia*
, /dev/nvhost*
and /dev/nvmap
with docker run option --device
. Share /dev/dri
and /dev/vga_arbiter
, too. Add container user to groups video
and render
with --group-add video --group-add render
.