Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Tearing in games (run using wine/lutis/steam) with Nvidia RTX 4090 and docker-nvidia-egl-desktop #918

Open
srinidhikrs opened this issue Feb 11, 2025 · 3 comments

Comments

@srinidhikrs
Copy link

I am using docker-nvidia-egl-desktop to launch containers on a headless server having NVIDIA RTX 4090 card , and streaming using webrtc . When I launch games using wine/lutris/steam ,with Xvfb resolution set to 1080p or higher, screen tear is visible in the center of the screen. But for resolutions 720p or lower no screen tear is visible.

While launching docker container if graphics is not included in (-e NVIDIA_DRIVER_CAPABILITIES=video) , tearing is not there in games with resolution of 1080p or higher . But GPU usage is very high (around 70 %) .

while launching docker container if --runtime=nvidia is added and graphics is included in -e NVIDIA_DRIVER_CAPABILITIES=video,graphics, tearing is present in games with resolutions of 1080p and higher . But GPU usage is very normal (around 10 %) .

root@gpuworstation:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy

root@gpuworstation:~# nvidia-smi
Tue Feb 11 06:56:42 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.86.16 Driver Version: 570.86.16 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| 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 4090 Off | 00000000:01:00.0 On | Off |
| 0% 35C P8 15W / 450W | 34MiB / 24564MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+

ii nvidia-container-toolkit 1.17.4-1 amd64 NVIDIA Container toolkit
ii nvidia-container-toolkit-base 1.17.4-1 amd64 NVIDIA Container Toolkit Base

Please help to resolve the screen tearing problem .

game_tear.mp4

In the attachment , it can be seen that the tear is happening in the game window only (movement left and right of flash white light) but not the entire desktop
And tearing is happening only with resolutions above 720p. (like 1080p , 1440p,.....) . But not for resolutions 720p or less

docker command :

docker run --ulimit nofile=1048576:1048576 --privileged --network=host --runtime=nvidia --name egl2 -v /FF7/:/home/ubuntu -it -d --gpus 1 --tmpfs /dev/shm:rw -e TZ=UTC -e DISPLAY_SIZEW=1920 -e DISPLAY_SIZEH=1080 -e DISPLAY_REFRESH=60 -e DISPLAY_DPI=96 -e DISPLAY_CDEPTH=24 -e PASSWD=mypasswd -e SELKIES_ENCODER=nvh264enc -e SELKIES_VIDEO_BITRATE=6000 -e SELKIES_FRAMERATE=60 -e SELKIES_AUDIO_BITRATE=128000 -e SELKIES_BASIC_AUTH_PASSWORD=mypasswd -e DISPLAY=:33 -e NGINX_PORT=8084 -e SELKIES_PORT=8085 -e SELKIES_METRICS_HTTP_PORT=8123 -e __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 -e __GL_SHADER_DISK_CACHE_PATH=/home/ubuntu/sc2 -e __GL_MaxFramesAllowed=1 -e SELKIES_RTC_CONFIG_JSON=/home/ubuntu/rtc.json -e NVIDIA_DRIVER_CAPABILITIES=video ghcr.io/selkies-project/nvidia-egl-desktop:24.04-jstest

Thanks
Srinidhi

@ehfd
Copy link
Contributor

ehfd commented Feb 14, 2025

@elezar Hi, Evan.

Let me elaborate a bit here.

The issue happens in 560.35.03 and 570.86.16.

Container toolkit version:

NVIDIA Container Toolkit CLI version 1.17.4
commit: 9b69590c7428470a72f2ae05f826412976af1395
GL_RENDERER   = NVIDIA GeForce RTX 4090/PCIe/SSE2
GL_VERSION    = 4.6.0 NVIDIA 560.35.03
GL_VENDOR     = NVIDIA Corporation

The methodology being incorporated here is identical to the virtual Vulkan X11 swapshain described in https://forums.developer.nvidia.com/t/headless-vulkan-with-multiple-gpus/222832/15 and https://forums.developer.nvidia.com/t/headless-vulkan-with-multiple-gpus/222832/9.

More references: VirtualGL/virtualgl#273 (comment)

Below, Final Fantasy VII Remake is used with the flag -d3d11 by @srinidhikrs, which uses DXVK.

(1) So in short, the issue is a massive level of tearing when using a virtual X11 server, such as Xvfb, combined with the above virtual Vulkan X11 swapchain. Here, NVIDIA_DRIVER_CAPABILITIES=all was used, as omitting graphics or display obviously does not work at all in an unprivileged environment.

Results of running some basic tests:

nonprivileged.zip

(1-1) Tearing persists when -e VKD3D_FRAME_RATE=60 -e DXVK_FRAME_RATE=60 were added to the above configuration (see Number 3 for why I added this).

Results:

dxvknonprov.zip

(2) The tearing issue happening above does not exist when using an Xorg server with nvidia Xorg drivers. So it is only an issue in combination with the virtual Vulkan X11 swapchain plus a virtual X11 server such as Xvfb. Here, NVIDIA_DRIVER_CAPABILITIES=all was used.

Using the Xorg server with nvidia Xorg drivers (great glxgears -info framerate with no tearing issues):

glx_display_graphics.zip

(3) One interesting additional finding was that for some reason, when using --privileged with Docker, and when using a virtual X11 server (Xvfb) with the virtual Vulkan X11 swapchain, where only -e NVIDIA_DRIVER_CAPABILITIES=video was used in Docker with --runtime=nvidia/--gpus 1 (most critical part being where there is no display or graphics in NVIDIA_DRIVER_CAPABILITIES), there was no tearing with the VKD3D/DXVK workload, along with a subtle (about 20%) increase in frames for glxgears -info.

However, GPU usage on RTX 4090 spikes to 70% for the Final Fantasy VII Remake game (indicating a suboptimal rendering path?). This is the result for the videoonly folder in the below egltest.zip file.

When -e VKD3D_FRAME_RATE=60 -e DXVK_FRAME_RATE=60 were added to the above configuration, the GPU usage came back to 18-20%, still without any tearing, which is a good thing to see.

(4) However, there was substantial tearing happening when either display or graphics got included in NVIDIA_DRIVER_CAPABILITIES, when using --privileged with Docker with --runtime=nvidia /--gpus 1, and when using a virtual X11 server (Xvfb) with the virtual Vulkan X11 swapchain, but the GPU usage on RTX 4090 was stable at 18-20%. In contrast, glxgears -info framerates slightly decreased by around 20% compared to Number 3. The results for this scenario are all the other folders than the videoonly folder in the below egltest.zip file.

Results of running basic tests when using --privileged with Docker:

egltest.zip

@ehfd
Copy link
Contributor

ehfd commented Feb 14, 2025

@ehfd
Copy link
Contributor

ehfd commented Feb 16, 2025

Referring @aaronp24 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants