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

Poor performance with nvenc #176

Closed
h0m3 opened this issue Jun 8, 2022 · 10 comments
Closed

Poor performance with nvenc #176

h0m3 opened this issue Jun 8, 2022 · 10 comments
Labels
os:Linux:Arch OS is Arch Linux stale

Comments

@h0m3
Copy link

h0m3 commented Jun 8, 2022

Describe the Bug

Im having a very poor performance while streaming with nvenc at 4K. Looks like its Software Encoding even after forcing with encoder = nvenc and checking out on the log that its actually using nvenc:

[2022:06:08:15:05:43]: Info: Found encoder nvenc: [h264_nvenc, hevc_nvenc]
[2022:06:08:15:05:43]: Info: Configuration UI available at [https://localhost:47990]
[2022:06:08:15:05:43]: Info: Adding avahi service Sunshine
[2022:06:08:15:05:44]: Info: Avahi service Sunshine successfully established.

My transmitting FPS is close to 40 and I have a very high input latency, close to unusable even on desktop.

Expected Behavior

60 FPS on desktop and a lower latency

Additional Context

I already successfully encoded at higher FPS and lower latency on the same computer but it was a while since I've used sunshine.

Sunshine Host Operating System and Version

Arch Linux

Architecture

64 Bit

Sunshine Version

0.13.0

GPU Type

Nvidia

GPU Model

GeForce RTX 3080

GPU Driver/Mesa Version

515.48.07

Capture Method (Linux Only)

No response

@KuleRucket
Copy link
Contributor

KuleRucket commented Jun 8, 2022

  1. use nvidia-utils-nvlax from AUR instead of nvidia-utils for patched nvidia drivers to enable nvfbc.
  2. add 'cuda' 'libdrm' 'libcap' to "depends =" in PKGBUILD
  3. use nightly branch in PKGBUILD:
    source=("$pkgname::git+https://github.com/SunshineStream/sunshine.git#branch=nightly"
  4. makepkg -cis instead of using a manager like yay

At the moment I would guess that you are CPU bound on one processor as you are not hardware encoding properly.
With an RTX 3070 I can get 100fps@4k using the above steps

@ReenigneArcher ReenigneArcher added the os:Linux:Arch OS is Arch Linux label Jun 8, 2022
@KuleRucket
Copy link
Contributor

If it's all fine you should see these info messages within the log output:
Info: Screencasting with NvFBC

@h0m3
Copy link
Author

h0m3 commented Jun 9, 2022

  1. use nvidia-utils-nvlax from AUR instead of nvidia-utils for patched nvidia drivers to enable nvfbc.

    1. add 'cuda' 'libdrm' 'libcap' to "depends =" in PKGBUILD

    2. use nightly branch in PKGBUILD:
      source=("$pkgname::git+https://github.com/SunshineStream/sunshine.git#branch=nightly"

    3. makepkg -cis instead of using a manager like yay

At the moment I would guess that you are CPU bound on one processor as you are not hardware encoding properly. With an RTX 3070 I can get 100fps@4k using the above steps

Hello my friend,

After following your recommendations I was able to start encoding with NvFBC agian. I still need to check out what was the change that fixed it.

  1. I was running nvidia-utils-nvlax but i've installed with yay
  2. cuda, libdrm and libcab where installed but i've added to nvlax PKGBUILD as you suggested
  3. I was using the stable branch from the AUR repo
  4. I was using yay

As soon as I have any free time i'll go backwards to find what went wrong ;)

@KuleRucket
Copy link
Contributor

yay is fine for nvlax, but you can't use it for sunshine because of all the edits you need to make. Once 0.14.0 is released you can move off the nightly again an back to normal.

cuda, libdrm and libcab go into the sunshine PKGBUILD not nvlax.

@h0m3
Copy link
Author

h0m3 commented Jun 9, 2022

yay is fine for nvlax, but you can't use it for sunshine because of all the edits you need to make. Once 0.14.0 is released you can move off the nightly again an back to normal.

cuda, libdrm and libcab go into the sunshine PKGBUILD not nvlax.

Thanks, i'll keep with nightly until v0.14.0.

The problem is with current v0.13.0 thats downloaded from AUR?

@KuleRucket
Copy link
Contributor

You main problem I think is that nvenc will not work unless you have cuda as a dependency. nvlax will give you better performance at higher fps. Using nightly will give you quite a lot of bug fixes but isn't essential.

@github-actions
Copy link

github-actions bot commented Aug 9, 2022

This issue is stale because it has been open for 30 days with no activity. Remove the stale label or comment, otherwise this will be closed in 5 days.

@github-actions github-actions bot added the stale label Aug 9, 2022
@ddulic
Copy link

ddulic commented Aug 16, 2022

Hello, I believe this issue relates to my experiences as well.

I am attempting to replace my Windows box with Linux Manjaro, the primary use-case is gaming via Steam.

Everything works locally, even via Proton for Windows Games, but I am having difficulties with streaming games to my TV. I tried Steam Remote Play, but I could never make it work, even with gamescope.

I read good things about Sunshine, especially on Linux, so I decided to give it a go, and it is working better, but I feel like there is still a delay that I can't explain.

Below is my system info

> nvidia-smi                                                                                                                                                                                                                                                                                                                          
Tue Aug 16 09:53:48 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01    Driver Version: 515.65.01    CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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 ...  Off  | 00000000:2B:00.0  On |                  N/A |
|  0%   41C    P8    18W / 240W |   1274MiB /  8192MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       621      G   /usr/lib/Xorg                     455MiB |
|    0   N/A  N/A       764      G   /usr/bin/kwin_x11                 131MiB |
|    0   N/A  N/A       818      G   /usr/bin/plasmashell              112MiB |
|    0   N/A  N/A      1149      G   ...e/Steam/ubuntu12_32/steam       28MiB |
|    0   N/A  N/A      1292      G   ...ef_log.txt --shared-files       82MiB |
|    0   N/A  N/A      2843    C+G   /usr/bin/sunshine                 235MiB |
|    0   N/A  N/A      5781      G   /usr/lib/firefox/firefox          214MiB |
+-----------------------------------------------------------------------------+
> sunshine --version                                                                                                                                                                                                                                                                                                                  
[fps] -- [[10,30,60,90,120]]
[vt_coder] -- [auto]
[amd_rc] -- [auto]
[vt_realtime] -- [enabled]
[key_rightalt_to_key_win] -- [disabled]
[resolutions] -- [[
    352x240,
    480x360,
    858x480,
    1280x720,
    1920x1080,
    2560x1080,
    3440x1440,
    1920x1200,
    3860x2160,
    3840x1600
]]
[origin_pin_allowed] -- [pc]
[gamepad] -- [x360]
[nv_coder] -- [cavlc]
[dwmflush] -- [enabled]
[min_log_level] -- [2]
[nv_rc] -- [cbr]
[hevc_mode] -- [0]
[nv_preset] -- [llhp]
[upnp] -- [disabled]
[amd_coder] -- [auto]
[vt_software] -- [auto]
[origin_web_ui_allowed] -- [lan]
[amd_quality] -- [default]
Sunshine version: v0.14.1
Startup encoder info
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Found [1] outputs
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Virtual Desktop: 2560x1440
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: XrandR: available
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: -- Output --
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info:   Resolution: 2560x1440
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info:   Offset: 0x0
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Error: Couldn't destroy session handle: Unable to cleanup NvFBC
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Error: Failed to gain CAP_SYS_ADMIN
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Error: Environment variable WAYLAND_DISPLAY has not been defined
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Detecting connected monitors
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //////////////////////////////////////////////////////////////////
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //                                                              //
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //   Testing for available encoders, this may generate errors.  //
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //   You can safely ignore those errors.                        //
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //                                                              //
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: //////////////////////////////////////////////////////////////////
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Trying encoder [nvenc]
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Screencasting with NvFBC
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Color coding [Rec. 601]
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Color range: [JPEG]
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Screencasting with NvFBC
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Color coding [Rec. 601]
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Color range: [JPEG]
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:51 Beasty sunshine[2843]: [2022:08:16:09:40:51]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 601]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 601]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 601]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 709]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Could not open codec [h264_nvenc]: Function not implemented
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 709]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: cuda::cuda_t doesn't support any format other than AV_PIX_FMT_NV12
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 601]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Screencasting with NvFBC
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color coding [Rec. 601]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Color range: [JPEG]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Warning: nvenc: hevc: replacing nalu prefix data
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Couldn't destroy session handle: The context is not bound
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info:
Short Session Logs
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Found encoder nvenc: [h264_nvenc, hevc_nvenc]
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Error: Failed to create client: Daemon not running
Aug 16 09:40:52 Beasty sunshine[2843]: [2022:08:16:09:40:52]: Info: Configuration UI available at [https://localhost:47990]
Aug 16 09:42:02 Beasty sunshine[2843]: [2022:08:16:09:42:02]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:04 Beasty sunshine[2843]: [2022:08:16:09:42:04]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:04 Beasty sunshine[2843]: [2022:08:16:09:42:04]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:04 Beasty sunshine[2843]: [2022:08:16:09:42:04]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:06 Beasty sunshine[2843]: [2022:08:16:09:42:06]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:08 Beasty sunshine[2843]: [2022:08:16:09:42:08]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Spawning [setsid steam steam://open/bigpicture]
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: CLIENT CONNECTED
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Found [1] outputs
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Virtual Desktop: 2560x1440
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: XrandR: available
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: -- Output --
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info:   Resolution: 2560x1440
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info:   Offset: 0x0
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Error: Couldn't destroy session handle: Unable to cleanup NvFBC
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Screencasting with NvFBC
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Color coding [Rec. 601]
Aug 16 09:42:09 Beasty sunshine[2843]: [2022:08:16:09:42:09]: Info: Color range: [MPEG]
Aug 16 09:42:10 Beasty sunshine[2843]: [2022:08:16:09:42:10]: Info: Setting default sink to: [sink-sunshine-stereo]
Aug 16 09:42:10 Beasty sunshine[2843]: [2022:08:16:09:42:10]: Info: Found default monitor by name: sink-sunshine-stereo.monitor
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: CLIENT DISCONNECTED
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: Setting default sink to: [alsa_output.pci-0000_2b_00.1.hdmi-stereo-extra1]
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Error: Couldn't destroy session handle: Unable to cleanup NvFBC
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Error: Couldn't release NvFBC context from current thread: Unable to cleanup NvFBC
Aug 16 09:44:24 Beasty sunshine[2843]: [2022:08:16:09:44:24]: Info: /CN=NVIDIA GameStream Client -- verified
Aug 16 09:44:26 Beasty sunshine[2843]: [2022:08:16:09:44:26]: Info: /CN=NVIDIA GameStream Client -- verified

Likewise, I have done the following:

If you also look at the session above, for some reason it disconnects and then reconnects again? The above game is a Proton game - Hellblade: Senua's Sacrifice. I am downloading another Proton game and will test soon.

I have also tried a native game - Valheim, thinking it might be a Proton issue, but I believe the same issue is present.

One additional note that I am not sure would cause issues, but wanted to mention anyway is that I have a 3440x1440p Primary Display (43:18 aspect ratio) and to not have black borders when I cast to my 4k TV (moonshine currently set to 1080p), I had to change the Primary Display's resolution to 2560x1440p. This might be a separate issue on its own, but I'm ignoring for now until the main issue is resolved. https://github.com/LizardByte/Sunshine/discussions/335#discussion-4311113

Thanks!

@LizardByte-bot
Copy link
Member

This issue is stale because it has been open for 90 days with no activity. Comment or remove the stale label, otherwise this will be closed in 10 days.

@LizardByte-bot
Copy link
Member

This issue was closed because it has been stalled for 10 days with no activity.

@LizardByte-bot LizardByte-bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:Linux:Arch OS is Arch Linux stale
Projects
None yet
Development

No branches or pull requests

5 participants