Hi, my first post here.
I am not sure what is happening, but for some reasons applications which are supposed to use GPU inside Docker containers in our server don’t actually use GPU, at least based on nvidia-smi
reading.
As an example, I will use Ogre3D sample applications.
My steps are mostly as follows. I apologize that I can’t reveal some details, so it’s not really an MWE. But hopefully this can still give an idea.
-
My workstation already has NVIDIA container toolkit.
-
My directory consists of three files:
-
build_ogre_linux_c++11.sh
from the Quick Start scripts for Ogre 2.3 - A
Dockerfile
(below, but the base image is a dummy one) - A
docker-compose.yml
(below)
-
-
Run
docker-compose up -d --build
to build and run the container. This will also build Ogre inside the container. -
Set up port forwarding (I use VS Code + SSH) and VNC to access the container’s desktop.
-
Inside the Docker container, run one of the Samples application, for example
./Sample_HDR
.- At this point I had to disable the Vulkan rendering subsystem, as for some reasons it’s not working. I use OpenGL 3+ instead.
- These are some lines that were printed.
Created GL 4.5 context
GLXWindow::create used FBConfigID = 400
GL Version = 4.5.0.0
GL_VERSION = 4.5 (Core Profile) Mesa 23.1.2 - kisak-mesa PPA
GL_VENDOR = Mesa
GL_RENDERER = llvmpipe (LLVM 15.0.7, 256 bits)
...
**************************************
*** OpenGL 3+ Renderer Started ***
**************************************
Registering ResourceManager for type GpuProgram
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL 3+ Rendering Subsystem
GPU Vendor: unknown
Device Name: llvmpipe (LLVM 15.0.7, 256 bits)
Driver Version: 4.5.0.0
- While the Ogre sample application is running, run
nvidia-smi
from outside the Docker container. I expected to see./Sample_HDR
too, but it was not printed.
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 530.30.02 Driver Version: 530.30.02 CUDA Version: 12.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 NVIDIA GeForce RTX 2080 Ti On | 00000000:41:00.0 Off | N/A |
| 19% 25C P8 3W / 250W| 66MiB / 11264MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 2120 G /usr/lib/xorg/Xorg 56MiB |
| 0 N/A N/A 2284 G /usr/bin/gnome-shell 7MiB |
+---------------------------------------------------------------------------------------+
I would appreciate any help on this matter. Thank you!
The Dockerfile is:
# Have CUDA, VNC, packages related to software development installed
FROM my_base_image
# Set the working directory
WORKDIR /root
ADD . .
# Install needed packages
RUN apt-get update && apt-get install -qq -y \
libgl1-mesa-glx \
libgl1-mesa-dri \
libxcb-randr0-dev \
xcb \
libxcb-xkb-dev \
x11-xkb-utils \
libx11-xcb-dev \
libxkbcommon-x11-dev \
libxtst-dev \
&& rm -rf /var/lib/apt/lists/* \
&& bash ./build_ogre_linux_c++11.sh
CMD ["bash"]
The docker-compose.yml
is:
version: '3.8'
services:
ogre:
build: .
working_dir: /root
image: ogre
container_name: ogre
ports:
- "60000:5900"
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=all
deploy:
resources:
reservations:
devices:
- driver: nvidia
capabilities: [gpu]