NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.51k stars 12.99k forks source link

Sunshine won't work with Cuda #305891

Open tymscar opened 2 months ago

tymscar commented 2 months ago

Describe the bug

Most of the sunshine versions posted on nixpkgs do not work with CUDA enabled. I have tried manually to pin sunshine to each of the last 20 commits and only around 5 managed to detect my display/encoder at startup. The nixpkgs revision that works with my machine is 56aeedf456e676d46af2595c3f66de9cf95f2cdd. That is sunshine v21.0

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install sunshine directly, or using the new service, with pkgs.sunshine.override { cudaSupport = true; };
  2. Run sunshine
  3. Try to connect or go to the homepage where you will see the errors at the top of the page

Expected behavior

I would expect every version to work like the one from revision 56aeedf456e676d46af2595c3f66de9cf95f2cdd where it would detect my gpu, my screen and codecs.

Additional context

The errors I am getting on the homepage are:

Attention! Sunshine detected these errors during startup. We STRONGLY RECOMMEND fixing them before streaming.
- Fatal: Unable to find display or encoder during startup.
- Fatal: Please ensure your manually chosen GPU and monitor are connected and powered on.

Here are the full logs:

[2024:04:22:04:35:40]: Info: Sunshine version: 0.22.2
[2024:04:22:04:35:40]: Error: Couldn't initialize cuda: CUDA_ERROR_SYSTEM_DRIVER_MISMATCH:system has unsupported display driver / cuda driver combination
[2024:04:22:04:35:40]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:40]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:40]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:40]: Info: System tray created
[2024:04:22:04:35:40]: Error: Environment variable WAYLAND_DISPLAY has not been defined
[2024:04:22:04:35:40]: Info: Detecting monitors
[2024:04:22:04:35:40]: Info: Detected monitor 0: HDMI-0, connected: true
[2024:04:22:04:35:40]: Info: Detected monitor 1: DP-0, connected: true
[2024:04:22:04:35:40]: Info: Detected monitor 2: DP-1, connected: false
[2024:04:22:04:35:40]: Info: Detected monitor 3: DP-2, connected: false
[2024:04:22:04:35:40]: Info: Detected monitor 4: DP-3, connected: true
[2024:04:22:04:35:40]: Info: Detected monitor 5: DP-4, connected: false
[2024:04:22:04:35:40]: Info: Detected monitor 6: DP-5, connected: false
[2024:04:22:04:35:40]: Info: Trying encoder [nvenc]
[2024:04:22:04:35:40]: Info: Screencasting with KMS
[2024:04:22:04:35:40]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:40]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:40]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:40]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:40]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:40]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:40]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:40]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:40]: Info: Screencasting with KMS
[2024:04:22:04:35:40]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:40]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:40]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:40]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:40]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:40]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:40]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:40]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: Encoder [nvenc] failed
[2024:04:22:04:35:41]: Error: Couldn't find any working encoder matching [nvenc]
[2024:04:22:04:35:41]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:04:22:04:35:41]: Info: Trying encoder [vaapi]
[2024:04:22:04:35:41]: Info: Screencasting with KMS
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: Screencasting with KMS
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: Encoder [vaapi] failed
[2024:04:22:04:35:41]: Info: Trying encoder [software]
[2024:04:22:04:35:41]: Info: Screencasting with KMS
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: Screencasting with KMS
[2024:04:22:04:35:41]: Info: /dev/dri/card0 -> simpledrm
[2024:04:22:04:35:41]: Warning: No render device name for: /dev/dri/card0
[2024:04:22:04:35:41]: Info: /dev/dri/card1 -> nvidia-drm
[2024:04:22:04:35:41]: Error: Couldn't find monitor [1]
[2024:04:22:04:35:41]: Info: Encoder [software] failed
[2024:04:22:04:35:41]: Fatal: Unable to find display or encoder during startup.
[2024:04:22:04:35:41]: Fatal: Please ensure your manually chosen GPU and monitor are connected and powered on.
[2024:04:22:04:35:41]: Error: Video failed to find working encoder
[2024:04:22:04:35:41]: Info: Adding avahi service Sunshine
[2024:04:22:04:35:41]: Info: Configuration UI available at [https://localhost:47990]
[2024:04:22:04:35:42]: Info: Avahi service Sunshine successfully established.

Notify maintainers

@devusb

Metadata

λ ~/ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.6, NixOS, 24.05 (Uakari), 24.05.20240421.f2d7a28`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/store/9hisakick7wdjhafbwmiz6bbhqybkajy-source`

Add a :+1: reaction to issues you find important.

tymscar commented 2 months ago

I have tried a reboot as mentioned by #305688 but it does not fix this particular issue.

DieracDelta commented 2 months ago

Reproduced on nixos. Hardware (not sure if it matters) 5950x + 4090 running NixOS unstable. Command used to reproduce:

nix shell -L --expr 'let nixpkgs_r = builtins.getFlake "github:NixOS/nixpkgs/c230c3ecc26a8390b94e7202769365c4ef93b8e2"; in let pkgs = import nixpkgs_r { system = "x86_64-linux"; config = { allowUnfree = true; }; }; in with pkgs; (sunshine.override {cudaSupport = true;})'

then sudo sunshine

image image

luochen1990 commented 1 month ago

sunshine.override {cudaSupport = true;} seems changed something, but there is still another problem: with it, the black screen shows some text: "Bluetooth: hci0: No support for _PRR ACPI method"

After reboot, there is still black screen:

$ vainfo --display drm --device /dev/dri/renderD128 |                 grep -E "((VAProfileH264High|VAProfileHEVCMain|VAProfileHEVCMain10).*VAEntrypointEncSlice)|Driver version"
libva info: VA-API version 1.21.0
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
libva info: va_openDriver() returns 1
vaInitialize failed with error code 1 (operation failed),exit

My Machine:

$ neofetch --stdout
lc@home-pc
----------
OS: NixOS 24.05.20240515.33d1e75 (Uakari) x86_64
Host: ASUSTeK COMPUTER INC. TUF GAMING X670E-PLUS
Kernel: 6.6.30
Uptime: 21 mins
Packages: 2915 (nix-system), 244 (nix-user)
Shell: zsh 5.9
Resolution: 3840x2160
DE: Plasma 5.27.11
WM: KWin
Icons: Papirus-Dark [GTK2/3]
Terminal: .konsole-wrappe
CPU: AMD Ryzen 9 7950X (32) @ 5.000GHz
GPU: AMD ATI Raphael
GPU: NVIDIA GeForce RTX 4090
Memory: 7303MiB / 63429MiB

and, I found that the sunshine nixos module doesn't work with journalctl:

$ journalctl -u sunshine
-- No entries --
tymscar commented 1 month ago

I think one of the issues with Bluetooth: hci0: No support for _PRR ACPI method we're solved by downgrading to revision 56aeedf456e676d46af2595c3f66de9cf95f2cdd. Can you give that a go @luochen1990 ?

Garulf commented 3 weeks ago

After upgrading from NixOS 23.11 to 24.05 I am seeing the exact same error with sunshine.

Config:

{ config, pkgs, lib, ...}:

let
  sunshineOverride = pkgs.sunshine.override {
    cudaSupport = true;
    stdenv = pkgs.cudaPackages.backendStdenv;
  };
in

with lib;

{

  environment.systemPackages = with pkgs; [
    sunshineOverride
  ];

  services.sunshine = {
    package = sunshineOverride;
    enable = true;
    autoStart = true;
    capSysAdmin = true;
    openFirewall = true;
  };
}

Is this ' following "stdenv" a typo on unstable?

https://github.com/NixOS/nixpkgs/blob/57d6973abba7ea108bac64ae7629e7431e0199b6/pkgs/servers/sunshine/default.nix#L51

Garulf commented 3 weeks ago

Suddenly started working after forcing the capture method?

image

image

Haven't fully tested yet.

tymscar commented 3 weeks ago

Is this ' following "stdenv" a typo on unstable?

No, that's normal. It's a convention called prime notation.

Suddenly started working after forcing the capture method?

That does not work for me sadly.

vavakado commented 5 days ago

For me trying to force the capture method worked only on X11 but not wayland

illustris commented 4 days ago

boot.kernelParams = ["nvidia_drm.fbdev=1"] fixed this for me on X11. If your error logs complain about simpledrm, this might work.