flathub / com.obsproject.Studio

This repository is no longer used to build OBS. Issues should be reported at https://github.com/obsproject/obs-studio
https://github.com/obsproject/obs-studio
29 stars 19 forks source link

Cannot use NVENC #8

Closed psy-q closed 5 years ago

psy-q commented 6 years ago

I have an Nvidia GTX 1060 and standalone OBS can use NVENC on it. With the Flatpak, It seems to detect it fine when starting:

info: NVENC supported

But when I actually try to use it, a dialog pops up saying NVENC couldn't be initialized and to check for latest drivers. Other flatpaks that make use of the Nvidia drivers work (e.g. the Dolphin emulator). In the log I get:

info: [NVENC encoder: 'streaming_h264'] settings:
        rate_control: CBR
        bitrate:      5000
        cqp:          0
        keyint:       120
        preset:       default
        profile:      high
        level:        auto
        width:        1920
        height:       1080
        2-pass:       true
        b-frames:     2
        GPU:          0

[h264_nvenc @ 0x7d1aea0] Cannot init CUDA
warning: [NVENC encoder: 'streaming_h264'] Failed to open NVENC codec: Unknown error occurred

The card is seen as such:

info: Initializing OpenGL...
info: Loading up OpenGL on adapter NVIDIA Corporation GeForce GTX 1060 6GB/PCIe/SSE2
info: OpenGL loaded successfully, version 3.2.0 NVIDIA 396.51, shading language 1.50 NVIDIA via Cg compiler
info: ---------------------------------
info: video settings reset:
        base resolution:   1920x1080
        output resolution: 1920x1080
        downscale filter:  Bicubic
        fps:               60/1
        format:            NV12
        YUV mode:          601/Partial

What could be the cause?

dotWAVE commented 6 years ago

I'm seeing this same issue. Trying to use Custom Output (FFmpeg) behaves the same way unfortunately. Steps to reproduce:

  1. In recording tab, set "Type" to "Custom Output (FFmpeg)"
  2. Set "Container Format" to "hevc"
  3. Set "Video Encoder" to "nvenc_hevc"
  4. Try to record a session, an error message appears. "An unspecified error occurred while recording."

The following output in terminal:

warning: Failed to open video codec: Unknown error occurred
warning: ffmpeg_data_init failed
TingPing commented 5 years ago

Ok so I looked into this and the problem seems to be that the nvidia-uvm module needs to be loaded and configured on the host. This cannot be done from within Flatpak.

On Fedora with RPMFusion this was done by just installing xorg-x11-drv-nvidia-cuda and rebooting.

TingPing commented 5 years ago

I am documenting this here: https://github.com/flathub/com.obsproject.Studio/wiki/NVENC-Support

Please let me know if you have any instructions for other distros.

psy-q commented 5 years ago

Hmm, I am using the Nvidia driver from the installers on the Nvidia site because the ones in Debian are massively outdated. Running a copy of OBS compiled myself directly on the host seems to work fine with NVENC without adding any CUDA-specific things to the system.

I'll try to find some CUDA test code to figure this out better.

TingPing commented 5 years ago

Yea using the installer makes your own pain, Nvidia has docs about it.

https://developer.download.nvidia.com/compute/cuda/6_0/rel/docs/CUDA_Getting_Started_Linux.pdf

Section 4.9 has a script.

TingPing commented 5 years ago

I'm not sure why the behavior would really be different on the host though, its not like user apps can make device nodes or load kernel modules.

dotWAVE commented 5 years ago

I have no trouble with NVENC when I compile OBS and FFMPEG myself, outside of flatpak of course.

TingPing commented 5 years ago

All I know is when I setup cuda on the host it worked fine in the Flatpak. If anybody finds some actionable information to better improve the package or docs let me know.