Nvidia rendering on Docker
I have an ubuntu 20.04 server with nvidia drivers up and running. The server is headless. If I run nvidia-smi
on the host machine, I get
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.38 Driver Version: 455.38 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 TITAN X (Pascal) Off | 00000000:01:00.0 Off | N/A |
| 23% 35C P8 16W / 250W | 51MiB / 12192MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 963 G /usr/lib/xorg/Xorg 49MiB |
+-----------------------------------------------------------------------------+
and if I run glxgears -display 0
I can through nvidia-smi that the GPU is working. Great! Now I want to do exactly the same thing on a docker machine! As an example, I will use the standard nvidia-docker image:
sudo docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 --rm --gpus all --entrypoint /bin/bash -it nvidia/cuda:11.0-base
in the docker container, I get glxgears:
apt update apt install mesa-utils -y
However, nvidia-smi here doesn't look as good:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.38 Driver Version: 455.38 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 TITAN X (Pascal) Off | 00000000:01:00.0 Off | N/A |
| 23% 34C P8 16W / 250W | 51MiB / 12192MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
And in fact glxgears
doesn't work:
root@75776a0b57b1:/# glxgears -display :0
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 151 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 43
Current serial number in output stream: 42
what am I doing wrong?