-
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.
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.
To ease things, x11docker allows automated install of nvidia driver in containers. Follow instructions given by x11docker terminal output or look at x11docker wiki: NVIDIA driver.
For a setup without automated install by x11docker, you need to install the driver matching your host driver version in image. The image will not be portable anymore.
- 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.
- Script to automatically build an NVIDIA base image matching the driver on host.
Share all files matching /dev/nvidia*
with docker run option --device
. Share /dev/dri
and /dev/vga_arbiter
, too.