Hello @KevinFFF . I think i finally found a solution to my problem.
I had to run a few steps before doing it though. If anyone out there needs to run rviz headlessly ( rviz_camera_stream plugin ) and display through hdmi at the same time. Here are the step i followed :
1 Disable Gdm and load drm at boot
sudo systemctl disable gdm
Then we will want to load drm kernel at boot.
For that add the following line to /etc/modules
file :
nvidia-drm
Now create or edit the following file /etc/modprobe.d/nvidia-drm.conf
. Then edid it
options nvidia-drm modeset=1
After making the changes, rebuild the initramfs (initial RAM filesystem) to ensure the module options are loaded at boot:
sudo update-initramfs -u
Reboot !!
sudo reboot
2 Do your Drm display here
For some wierd reason, launching xorg before using drm makes the gstreamer pipeline fail.
gst-launch-1.0 videotestsrc pattern=1 ! video/x-raw , width=1920 , height=1080 , format=NV12 , framerate=30/1 ! nvdrmvideosink sync=false ## Here you can use a real camera or an image for real display
3 Configure Xorg for headless setup
First create a new xorg configutaton file file to be able to use xord without any physical dislay at all
sudo vim /etc/X11/10-xorg-headless.conf
Add the following lines to the file :
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration" "True"
Option "UseDisplayDevice" "None"
EndSection
Start the X server without any display
sudo Xorg :99 -noreset +extension GLX +extension RANDR +extension RENDER -logfile /var/log/Xorg.99.log -config /etc/X11/10-xorg-headless.conf &
Now you can run an application requiring X on the gpu
sudo apt install mesa-utils
export DISPLAY=:99
glxinfo | grep OpenGL ## This will show you the device being used in the by the Xorg server
# rviz