nestriness / nestri

[Experimental] Open-source GeForce NOW alternative with Stadia's social features
https://nestri.io
GNU Affero General Public License v3.0
1.41k stars 18 forks source link

[🔁 Compatibility] Future compatibility with non-CUDA graphics cards #68

Open csolisr opened 4 weeks ago

csolisr commented 4 weeks ago

Are there any future plans to extend this project to be compatible with graphics cards not able to run CUDA? Or is the CUDA dependency unable to be removed in the future due to architectural design?

wanjohiryan commented 3 weeks ago

Hey there 👋🏽 @csolisr

What Nvidia graphics card are you using?

To use Nvenc we need Cuda, here is the error I get when Cuda is not on the latest v12.0 version

2024-04-17 11_57_13-ubuntu@9a0f7c498308_ ~
csolisr commented 3 weeks ago

Hey there 👋🏽 @csolisr

What Nvidia graphics card are you using?

An AMD 6600, so, not Nvidia. Are there any plans to make the stack compatible with OpenCL for example?

Dekomoro commented 3 weeks ago

For encoding, ffmpeg vaapi encoding would work on both intel and amd gpus and is likely the ideal route to go for amd support

dec05eba commented 3 weeks ago

Hey there 👋🏽 @csolisr

What Nvidia graphics card are you using?

To use Nvenc we need Cuda, here is the error I get when Cuda is not on the latest v12.0 version

2024-04-17 11_57_13-ubuntu@9a0f7c498308_ ~

Older nvidia gpus dont support cuda 12. The cuda 12 requirement comes from ffmpegs nv-codec-headers version n12 if I recall correctly so you can make it work on older nvidia gpus by building ffmpeg from source and using an older nv-codec-header dependency. This is what the flatpak version of gpu screen recorder does: https://github.com/flathub/com.dec05eba.gpu_screen_recorder/blob/master/com.dec05eba.gpu_screen_recorder.yml#L68 . The only downside of doing this that I'm aware of is that this newer version of nv-codec-headers is needed for av1 support.

An easier alternative would be to run the flatpak version of gpu screen recorder (assuming flatpak is easy to setup in docker and isn't too bloat, maybe it is). The flatpak version of gpu screen recorder comes with the cli for gpu screen recorder as well so it can be used as a drop-in replacement by replacing gpu-screen-recorder in the command with flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder, so for example gpu-screen-recorder -w screen -f 60 -o video.mp4 becomes flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder -w screen -f 60 -o video.mp4. The performance is the same and commands such as killall -SIGINT gpu-screen-recorder, killall -SIGUSR1 gpu-screen-recorder work with the flatpak version as well.

wanjohiryan commented 3 weeks ago

Hey y'all 👋🏽

Hi @dec05eba thanks for dropping by :)

@ehfd Can hardware accelerated Xorg run without Cuda?

ehfd commented 3 weeks ago

Can hardware accelerated Xorg run without Cuda?

@wanjohiryan Yes. It isn't really dependent on anything related to CUDA. However, screen capture and media encoding are different stories. They may require certain partial components of CUDA, although not the whole toolkit.

wanjohiryan commented 3 weeks ago

Well thanks @ehfd , then I think we might explore how to run Netris without relying on Cuda.

Which means we will be downloading gpu-screen-recorder using Flatpak.

dec05eba commented 3 weeks ago

@wanjohiryan I think there is a bit of a misunderstanding. When you record on nvidia it will always use cuda, but if you use the flatpak version then it will use that older nv-codec-headers which allows older versions of cuda that works on older nvidia gpus. If you want to record on amd/intel then there is no need to use the flatpak version.

wanjohiryan commented 3 weeks ago

Thank you for clarifying that @dec05eba

Okay, so by using the Flatpak version all it does is extend back to Nvidia graphics cards that use older than Cuda version 12, right?

Is this what you wanted @csolisr ? Support for Cuda version lower than 12?

dec05eba commented 3 weeks ago

Okay, so by using the Flatpak version all it does is extend back to Nvidia graphics cards that use older than Cuda version 12, right?

Correct. This is nvidia gpus that are more than 10 years old. But in this case @csolisr wants to use it on amd, not nvidia. The answer was specifically for the error you posted about with the image. This error doesn't appear when you are on amd/intel and dont have cuda at all.

ehfd commented 3 weeks ago

@wanjohiryan I can't speak for gpu-screen-recorder, but typically NVENC only requires libnvrtc.so out of all CUDA components.

RUN NVRTC_VERSION="11.4.152" && \
    NVRTC_ARCH="$(dpkg --print-architecture | sed -e 's/arm64/sbsa/' -e 's/ppc64el/ppc64le/' -e 's/i.*86/x86/' -e 's/amd64/x86_64/' -e 's/unknown/x86_64/')" && \
    cd /tmp && curl -fsSL "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/linux-${NVRTC_ARCH}/cuda_nvrtc-linux-${NVRTC_ARCH}-${NVRTC_VERSION}-archive.tar.xz" | tar -xJf - -C /tmp && mv -f cuda_nvrtc* cuda_nvrtc && cd cuda_nvrtc/lib && chmod 755 libnvrtc* && mv -f libnvrtc* /opt/gstreamer/lib/$(dpkg --print-architecture | sed -e 's/arm64/aarch64-linux-gnu/' -e 's/armhf/arm-linux-gnueabihf/' -e 's/riscv64/riscv64-linux-gnu/' -e 's/ppc64el/powerpc64le-linux-gnu/' -e 's/s390x/s390x-linux-gnu/' -e 's/i.*86/i386-linux-gnu/' -e 's/amd64/x86_64-linux-gnu/' -e 's/unknown/x86_64-linux-gnu/')/ && cd /tmp && rm -rf /tmp/cuda_nvrtc
DatCaptainHorse commented 2 weeks ago

I've hacked together modification for Nestri to work under recent Intel GPU's (Intel Arc in my case), as side-effect it might work under AMD GPU's. I'll try to clean and make my changes less "hacky" tomorrow or so, current issues are:

dec05eba commented 2 weeks ago

I've hacked together modification for Nestri to work under recent Intel GPU's (Intel Arc in my case), as side-effect it might work under AMD GPU's. I'll try to clean and make my changes less "hacky" tomorrow or so, current issues are:

  • gpu-screen-recorder doesn't play well with Intel GPU's, the capture uses some wrong format which causes artifacting, making it unusable. In my modifications I skipped gpu-screen-recorder and used ffmpeg's kmsgrab directly, however it doesn't capture the mouse cursor with the screen.
  • Some earlier Intel iGPU's might not work (atleast without heavier modifications), I tried with integrated "UHD Graphics P630" to no success.

If it works with ffmpeg kmsgrab then I can make it work with gpu screen recorder as well if you are willing to test it. The issue is tracked here: https://github.com/dec05eba/gpu-screen-recorder-issues/issues/1 if you comment there with system info (and drm_info output) then I can provide tests. This issue only happens with some intel systems so I cant test it myself as it doesn't happen with my older intel iGPU.