LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   ffmpeg compile with nvidia acceleration failed (https://www.linuxquestions.org/questions/slackware-14/ffmpeg-compile-with-nvidia-acceleration-failed-4175729366/)

zdolar 09-28-2023 05:48 AM

ffmpeg compile with nvidia acceleration failed
 
I have today updated Slackware64-current.
HP ZBook with Nvidia P2000
Installed:
nv-codec-headers-12.0.16.0-x86_64
nvidia-driver-535.113.01_multilib-x86_64
nvidia-kernel-535.113.01_6.4.16-x86_64

Nvidia krenel/driver test:
Code:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro P2000/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 535.113.01
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 535.113.01
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 535.113.01
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

Code:

ls -la /usr/include/ffnvcodec/
total 476
drwxr-xr-x  2 root root  4096 23.09.2023 09:46:50 .
drwxr-xr-x 603 root root  36864 28.09.2023 08:33:13 ..
-rw-r--r--  1 root root  21876 23.09.2023 09:46:50 dynlink_cuda.h
-rw-r--r--  1 root root  66364 23.09.2023 09:46:50 dynlink_cuviddec.h
-rw-r--r--  1 root root  22503 23.09.2023 09:46:50 dynlink_loader.h
-rw-r--r--  1 root root  28494 23.09.2023 09:46:50 dynlink_nvcuvid.h
-rw-r--r--  1 root root 291178 23.09.2023 09:46:50 nvEncodeAPI.h

compiling ffmpeg from slackware source or Aliens repository-restricted both do not compile nvidia hardware acclerated encoders. There are no nvenc encoders:
Code:

ffmpeg -hide_banner -encoders |grep H.26
 V..... flv                  FLV / Sorenson Spark / Sorenson H.263 (Flash Video) (codec flv1)
 V..... h261                H.261
 V..... h263                H.263 / H.263-1996
 V..... h263_v4l2m2m        V4L2 mem2mem H.263 encoder wrapper (codec h263)
 V.S... h263p                H.263+ / H.263-1998 / H.263 version 2
 V....D libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V....D libx264rgb          libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
 V..... h264_qsv            H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
 V..... h264_v4l2m2m        V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V....D h264_vaapi          H.264/AVC (VAAPI) (codec h264)
 V....D libx265              libx265 H.265 / HEVC (codec hevc)
 V....D hevc_vaapi          H.265/HEVC (VAAPI) (codec hevc)

Looks like autodetection of nv codec headers do not detect them, or something else is missing.
As a result ffmpeg is not nvidia accelerated.:(

Please help.

ReaperX7 09-28-2023 11:47 PM

Check the build instructions for an option to enable nvenc or edit the buildscript to enable it.

zdolar 09-29-2023 07:09 AM

Quote:

Originally Posted by ReaperX7 (Post 6456151)
Check the build instructions for an option to enable nvenc or edit the buildscript to enable it.

Yes I always RTFM.
All properly done by manuals/suggestions here and Nvidia.
What bothers me, is on nVidias page as Prerequisites:
To compile FFmpeg, the CUDA toolkit must be installed on the system, though the CUDA toolkit is not needed to run the FFmpeg compiled binary.
Previous versions do not require Cuda Toolkit to compile only nvenc and nvdec without Cuda acceleration.

For simple test I used pure ffmpeg-5.1.3 source and get undefined error as nvenc is not a library or dependency:
Code:

./configure  --prefix="$HOME/bin"  --bindir="$HOME/bin"  --disable-doc  --enable-static  --disable-shared  --enable-openssl  --enable-libvorbis  --enable-libmp3lame  --enable-libx264  --enable-libx265  --enable-libvpx  --enable-libopus  --enable-libfdk-aac  --enable-libtheora  --enable-zlib  --enable-libfreetype  --enable-libpulse  --enable-libfribidi  --enable-libass --enable-nvenc  --enable-gpl  --enable-nonfree
root@zbook ./configure  --prefix="$HOME/bin"  --bindir="$HOME/bin"  --disable-doc  --enable-static  --disable-shared  --enable-openssl  --enable-libvorbis  --enable-libmp3lame  --enable-libx264  --enable-libx265  --enable-libvpx  --enable-libopus  --enable-libfdk-aac  --enable-libtheora  --enable-zlib  --enable-libfreetype  --enable-libpulse  --enable-libfribidi  --enable-libass --enable-nvenc  --enable-gpl  --enable-nonfree
ERROR: nvenc requested but not found

As Cuda toolkit is massive, I prefer not to install it, if not needed.

zdolar 09-29-2023 09:01 AM

Installed cuda-12.2, the same error remains.:confused::banghead:

superkret2 09-29-2023 12:51 PM

Do you have libvdpau installed?
It's a dependency of nvidia-driver according to https://docs.slackware.com/howtos:ha...aphics_drivers

Also you might try this:

Code:

For CUDA/OpenCL to work after reboot, and for utilites such as
nvidia-smi, you might need to include the following line in your
/etc/rc.d/rc.local:
(This is REQUIRED if you plan on running nvidia-persistenced)

    # Create missing nvidia device nodes after reboot
    /usr/bin/nvidia-modprobe -c 0 -u


zdolar 10-19-2023 03:56 PM

Quote:

Originally Posted by superkret2 (Post 6456215)
Do you have libvdpau installed?
It's a dependency of nvidia-driver according to https://docs.slackware.com/howtos:ha...aphics_drivers

Also you might try this:

Code:

For CUDA/OpenCL to work after reboot, and for utilites such as
nvidia-smi, you might need to include the following line in your
/etc/rc.d/rc.local:
(This is REQUIRED if you plan on running nvidia-persistenced)

    # Create missing nvidia device nodes after reboot
    /usr/bin/nvidia-modprobe -c 0 -u


Yes:
/dev/nvidia-modeset
/dev/nvidia-uvm
/dev/nvidia-uvm-tools
/dev/nvidia0
/dev/nvidiactl

/dev/nvidia-caps:
nvidia-cap1
nvidia-cap2

I tested all I found on net, but no success.
I also reverted kernel/driver to 530.41.03.
ffmpeg config do not detect nvidia kernel modules and drivers.
Explicitly specified enable-nvenc in configure returns:
nvenc requested but not found.

Can anybody help?

zdolar 10-19-2023 04:17 PM

Part of config.log where error is:

Code:

clang: warning: CUDA version 12.1 is only partially supported [-Wunknown-cuda-version]
error: unable to create target: 'No available targets are compatible with triple "nvptx64-nvidia-cuda"'
1 error generated when compiling for sm_30.
check_pkg_config ffnvcodec ffnvcodec >= 9.1.23.1 ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h
test_pkg_config ffnvcodec ffnvcodec >= 9.1.23.1 ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h
pkg-config --exists --print-errors ffnvcodec >= 9.1.23.1
check_func_headers ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h
test_ld cc
test_cc
BEGIN /tmp/ffconf.BNgytSQg/test.c
    1        #include <ffnvcodec/nvEncodeAPI.h>
    2        #include <ffnvcodec/dynlink_cuda.h>
    3        #include <ffnvcodec/dynlink_cuviddec.h>
    4        #include <ffnvcodec/dynlink_nvcuvid.h>
    5        #include <stdint.h>
    6        int main(void) { int ret = 0;
    7        return ret; }
END /tmp/ffconf.BNgytSQg/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -O2 -fPIC -I/usr/local/cuda/include -std=c11 -fomit-frame-pointer -fPIC -c -o /tmp/ffconf.BNgytSQg/test.o /tmp/ffconf.BNgytSQg/test.c
gcc -L/usr/local/cuda/lib64 -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.BNgytSQg/test /tmp/ffconf.BNgytSQg/test.o
check_cpp_condition winrt windows.h !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
test_cpp_condition windows.h !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
test_cpp
BEGIN /tmp/ffconf.BNgytSQg/test.c
    1        #include <windows.h>
    2        #if !(!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
    3        #error "unsatisfied condition: !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
    4        #endif
END /tmp/ffconf.BNgytSQg/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -O2 -fPIC -I/usr/local/cuda/include -std=c11 -fomit-frame-pointer -fPIC -E -o /tmp/ffconf.BNgytSQg/test.o /tmp/ffconf.BNgytSQg/test.c
/tmp/ffconf.BNgytSQg/test.c:1:10: fatal error: windows.h: No such file or directory
    1 | #include <windows.h>
      |          ^~~~~~~~~~~
compilation terminated.


zdolar 10-27-2023 08:40 AM

:) Finally solved. :)

nv-codec-headers is responsible for many hours lost.
The right version is 11.1.5.3 - the last 11.X version.
Despite a new nvidia kernel/driver installed, nv-codec-headers must be < 12.X.
Works with the latest 545.23.06 kernel/driver.
All options are autodetected with original Pats ffmpeg.SlackBuild.
As I'm out of US, I set to compile patented and non_free code.

Geremia 03-26-2024 11:41 PM

Instructions for CUDA 12.x: https://docs.nvidia.com/video-techno...ling-for-linux

Geremia 03-27-2024 04:01 PM

be sure to update nv-codec-headers to correspond with your Cuda version
 
Quote:

Originally Posted by zdolar (Post 6461184)
All options are autodetected with original Pat's ffmpeg.SlackBuild.

Not for me. It didn't detect CUDA when I tried to build ffmpeg 6.1.1.

Update: I needed to update nv-codec-headers to 12.1.14.0, then the SlackBuild detected everything properly.


All times are GMT -5. The time now is 05:00 PM.