0

I have been working with docker, nvidia gpus and Display before in docker image. Inside which I am successfully able to initialize pygame.init()

with output (7,0)

After formatting my ubuntu machine. I installed docker and nvidia container toolkit to enable gpus inside the docker container.

however after I use xhost + and run following docker command and bash to running container.

docker run -it -e DISPLAY=$DISPLAY --gpus all <IMAGE ID>

Inside the container. I can see nvidia-smi working and nvcc --version working. And installed apt-get install -qqy x11-apps. However when I install pygame using pip install pygame

And initialize pygame with pygame.init() it throws me an error:

pygame.error: No available video device

I have already gone though: pygame.error: No available video device

and many other link.

Would like to know if I am missing any libraries. On host machine or inside docker container and for reference I am using following container

docker run -it -e DISPLAY=$DISPLAY --gpus all nvcr.io/nvidia/tensorflow:20.06-tf2-py3

Other commands which I already have tried thanks to Stackoverflow community are following docker run -it -e DISPLAY=$DISPLAY -v SOME UNIX SOCKET MOUNT --gpus all nvcr.io/nvidia/tensorflow:20.06-tf2-py3

How do I connect my display to pygame so pygame.init() or pygame.display.init() does not break inside docker container.

Note: Python version 3

UPDATE 1: I tried without gpus all option

docker run -it -e DISPLAY=$DISPLAY nvcr.io/nvidia/tensorflow:20.06-tf2-py3

However it still does not work

UPDATE 2: https://opeonikute.dev/posts/running-pygame-in-a-docker-container-macos

Followed attempt 4 section of above article and I see following error

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:  152 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  104
  Current serial number in output stream:  103

Update 3: Problem might be here https://github.com/NVIDIA/libglvnd

Since pygame work in nvidia/opengl base image but I want to use base image for nvcr.io/nvidia/tensorflow:20.06-tf2-py3

Jaskaran Singh
  • 531
  • 3
  • 14
  • 1
    is it even possible to run pygame on a graphics card? I thought it was CPU driven. or maybe I am missing a point – Matiiss Apr 09 '21 at 18:19
  • I am not sure graphic card I need for tensorflow not for pygame however i just tried to import os and os.environ["DISPLAY"] which outputs :1 which means display is connected to docker but pygame doesnst want to see it. :( – Jaskaran Singh Apr 09 '21 at 18:39
  • @Matiiss if you are on ubuntu system and have docker install can you please give it a shot.. – Jaskaran Singh Apr 09 '21 at 18:49
  • I'm on windows, so I can't, and to be honest I don't even know what a docker is. As I said earlier I may be missing a point which I now see I can't even understand. Since I understood that You want to run pygame on GPU so that is what I answered for. Neither do I have experience with tensorflow (maybe some time later) – Matiiss Apr 09 '21 at 18:52

0 Answers0