LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-06-2022, 11:11 AM   #1
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Rep: Reputation: 23
Rebuild FFmpeg fails with "nvidia-legacy340" driver installed


I've installed nvidia-legacy340 both kernel and driver, from SBo:

https://slackbuilds.org/repository/1...acy340-driver/

After this I noticed some issues with OpenCL:

Code:
/usr/lib64/libOpenCL.so.1.0.0
is overwritten by nvidia driver package, the default was from:

Code:
ocl-icd-2.3.1-x86_64-1
Runtime issues and warnings seem solved by reinstall this ocl-icd package for orig file restoring.
Anyway I was wondering if could be better to rebuild ffmpeg against the nvidia OpenCL version of that lib.

So I reinstalled nvidia driver, so that nvidia libOpenCL.so is in place and I've tried to build FFmpeg from source using Pat SlackBuild:

https://mirrors.slackware.com/slackw...urce/l/ffmpeg/

Anybody tried?
It returns this issue to me:
Code:
MAN     doc/libavformat.3
MAN     doc/libavdevice.3
MAN     doc/libavfilter.3
LD      libswscale/libswscale.so.5
LD      libpostproc/libpostproc.so.55
LD      libswresample/libswresample.so.3
LD      libavresample/libavresample.so.4
LD      libavcodec/libavcodec.so.58
LD      libavformat/libavformat.so.58
LD      libavfilter/libavfilter.so.7
LD      libavdevice/libavdevice.so.58
LD      ffmpeg_g
LD      ffplay_g
LD      ffprobe_g
/usr/bin/ld: libavutil/libavutil.so: undefined reference to `clGetExtensionFunctionAddressForPlatform'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clEnqueueFillBuffer'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clCreateImage'
collect2: error: ld returned 1 exit status
make: *** [Makefile:124: ffprobe_g] Errore 1
make: *** Attesa per i processi non terminati....
/usr/bin/ld: libavutil/libavutil.so: undefined reference to `clGetExtensionFunctionAddressForPlatform'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clEnqueueFillBuffer'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clCreateImage'
collect2: error: ld returned 1 exit status
make: *** [Makefile:124: ffplay_g] Errore 1
/usr/bin/ld: libavutil/libavutil.so: undefined reference to `clGetExtensionFunctionAddressForPlatform'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clEnqueueFillBuffer'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clCreateImage'
collect2: error: ld returned 1 exit status
make: *** [Makefile:124: ffmpeg_g] Errore 1
LD      ffmpeg_g
/usr/bin/ld: libavutil/libavutil.so: undefined reference to `clGetExtensionFunctionAddressForPlatform'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clEnqueueFillBuffer'
/usr/bin/ld: libavfilter/libavfilter.so: undefined reference to `clCreateImage'
collect2: error: ld returned 1 exit status
make: *** [Makefile:124: ffmpeg_g] Errore 1
It is possible to solve or only chance is to restore the OpenCL lib from official slack?
 
Old 06-06-2022, 12:48 PM   #2
RadicalDreamer
Senior Member
 
Registered: Jul 2016
Location: USA
Distribution: Slackware64-Current
Posts: 1,816

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
Try disabling opencl and then build ffmpeg. Change
Code:
opencl=""     ; [ "${OPENCL:-yes}" != "no" ]      && opencl="--enable-opencl"
to
Code:
opencl=""     ; [ "${OPENCL:-yes}" != "yes" ]      && opencl="--enable-opencl"
 
Old 06-06-2022, 01:36 PM   #3
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
I'll try and report here...

Anyway is this a right way to solve?
I'm trying to link FFmpeg to Nvidia libOpenCL.so, not to exclude OpenCL from FFmpeg.
 
Old 06-06-2022, 02:18 PM   #4
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
Just for report, disabling "opencl" make the above error disappeared:
Code:
MAN     doc/libavformat.3
MAN     doc/libavdevice.3
MAN     doc/libavfilter.3
LD      libswscale/libswscale.so.5
LD      libpostproc/libpostproc.so.55
LD      libswresample/libswresample.so.3
LD      libavresample/libavresample.so.4
LD      libavcodec/libavcodec.so.58
LD      libavformat/libavformat.so.58
LD      libavfilter/libavfilter.so.7
LD      libavdevice/libavdevice.so.58
LD      ffmpeg_g
LD      ffprobe_g
LD      ffplay_g
STRIP   ffmpeg
STRIP   ffplay
STRIP   ffprobe
But the question remains: how to build FFmpeg linking it properly to Nvidia libOpenCL.so.* ?
(if it is possible)
 
1 members found this post helpful.
Old 06-06-2022, 02:59 PM   #5
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
libOpenCL is a vendor neutral dispatching library, not an actual OpenCL implementation. Applications are built against that vendor neutral library so it doesn't matter which hardware is available at runtime. Consequently it should also not be replaced, nor overwritten. In that regard it works similar to how libvulkan and libglvnd work for Vulkan and OpenGL respectively.
 
Old 06-06-2022, 03:39 PM   #6
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,500

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
Quote:
Originally Posted by ppr:kut View Post
libOpenCL is a vendor neutral dispatching library, not an actual OpenCL implementation. Applications are built against that vendor neutral library so it doesn't matter which hardware is available at runtime. Consequently it should also not be replaced, nor overwritten. In that regard it works similar to how libvulkan and libglvnd work for Vulkan and OpenGL respectively.
Tell this to the guy who manages those NVIDIA SlackBuilds from SBo.

Looks like he has ZERO respect for things named like libOpenCL, libvulkan and libglvnd.

No offense intended, BUT his packages are so invasive (and I would say, destructive), that makes the puppies cries.
 
Old 06-06-2022, 03:47 PM   #7
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
So, Nvidia provides libOpenCL.so within their driver distribution (legacy340 in my case), while the one provided with vanilla slackware installation is "something different".

1. In what they differ exactly?
2. Why FFmpeg can link fine to the slackware libOpenCL.so, but returns build errors with the one provided by Nvidia?


EDIT:
I mailed SBo nvidia-legacy340 maintainer asking for infos about this issue, but no response for now.
I don't know if he are still monitoring and testing his slackbuild.
Hope my ignorant questions above could be useful to find a proper solution as well as help myself to better understand how it works under the hood.

Last edited by joenew; 06-06-2022 at 03:58 PM.
 
Old 06-06-2022, 03:57 PM   #8
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,500

Rep: Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308Reputation: 3308
Quote:
Originally Posted by joenew View Post
So, Nvidia provides libOpenCL.so within their driver distribution (legacy340 in my case), while the one provided with vanilla slackware installation is "something different".

1. In what they differ exactly?
2. Why FFmpeg can link fine to the slackware libOpenCL.so, but returns build errors with the one provided by Nvidia?
This "something different" means that they offer different API.

That's why you get build errors. They aren't compatible implementations - probably the versions differ.

Better to build your ffmpeg without OpenCL.
 
Old 06-07-2022, 01:34 AM   #9
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
libOpenCL in -current provides support for the latest OpenCL version, matching the headers. libOpenCL then internally checks which version the vendor supports. If you replace the system libOpenCL with a different one, especially a much older one like for the nvidia legacy drivers, the OpenCL version between lib and headers no longer matches.

But even if you update the headers as well, you have then other applications in Slackware that are linked against a libOpenCL that supports the newer OpenCL APIs that the older libOpenCL wouldn't support. It *should* be fine if the .so version matches, but there might be other things going wrong.
 
1 members found this post helpful.
Old 06-07-2022, 04:23 AM   #10
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
Maybe I understood inner workings a bit more... the dispatcher idea in particular. From "man libopencl", If I well understood, what in fact nvidia driver looking for are opencl-libs by scanning /etc/OpenCL/vendors/nvidia.icd. Here we have a record which defines libnvidia-opencl.so.1:
Code:
$ cat /etc/OpenCL/vendors/nvidia.icd 
libnvidia-opencl.so.1
Both nvidia.icd and following files are from nvidia driver package:
Code:
$ find /usr/lib* -name libnvidia-opencl* -exec file "{}" \; 2>/dev/null
/usr/lib/libnvidia-opencl.so.1: symbolic link to libnvidia-opencl.so.340.108
/usr/lib/libnvidia-opencl.so.340.108: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
/usr/lib64/libnvidia-opencl.so.1: symbolic link to libnvidia-opencl.so.340.108
/usr/lib64/libnvidia-opencl.so.340.108: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
So the driver provides its own old dispatcher libOpenCL.so, but the system has a newer dispatcher from OpenCL ICD loader (thnks to ocl-icd package). The behavior during FFmpeg build suggests that gcc or the linker or some other piece of the builder can't find libnvidia-opencl.so.1 through the old libOpenCL.so (provided with the driver), while it doesn't return any error with the new OpenCL dispatcher "slackware stock".
I would conclude that OpenCL from nvidia-legacy not only is unneeded, but it also breaks new OpenCL dispatcher, and it breaks opencl mechanism not just for nvidia but for any other modern program too. It causes useless opencl managing for the whole system.

So, libOpencl.so.1.0.0 has to be remove from the nvidia driver package, this is verified. A confirm is appreciated.
Anyway we could use some "acid test" to check whether nvidia OpenCL feature is really working properly using the new dispatcher provided by ocl-icd.
Could you suggest how to check it?
For instance, I could build FFmpeg with opencl enabled and ocl-icd dispatcher in place. It should compile and link without any issue. But how can I test then if ffmpeg can really use that feature?
 
Old 06-07-2022, 05:20 AM   #11
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
Quote:
Originally Posted by joenew View Post
Anyway we could use some "acid test" to check whether nvidia OpenCL feature is really working properly using the new dispatcher provided by ocl-icd.
Could you suggest how to check it?
to test if you have an opencl device available and working you can use a small C program called clinfo, you can find the SlackBuild here
https://ponce.cc/slackware/testing/clinfo/

Quote:
Originally Posted by joenew View Post
For instance, I could build FFmpeg with opencl enabled and ocl-icd dispatcher in place. It should compile and link without any issue. But how can I test then if ffmpeg can really use that feature?
at this link there should be some hints ffmpeg-specific: note that the command
Code:
ffmpeg -h filters | grep opencl
in the newer ffmpeg versions has become
Code:
ffmpeg -filters | grep opencl

Last edited by ponce; 06-07-2022 at 05:24 AM.
 
Old 06-07-2022, 08:39 AM   #12
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
Tried to edit original slackbuild so that it doesn't generate libOpenCL.so anymore. A patch is attached to this message.

After being sure to:

- removed nvidia-legacy340-driver (after launching nvidia-switch --remove)
- slackpkg reinstall ocl-icd
- install again the new nvidia package as changed through the patch
- rebuilt ffmpeg using Pat slackbuild with some additions:
Code:
#!/bin/sh
X264=yes \
ASS=yes \
AOM=yes \
DAV1D=yes \
./ffmpeg.SlackBuild
It builds properly without any issue, opencl support should be enabled by default.
After following Ponce instructions (thank you!) I share the output below:

Code:
$ ffmpeg -filters|grep opencl
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11.2.0 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-4.4.1/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-gpl --enable-version3 --enable-avresample --arch=x86_64 --disable-encoder=aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libcdio --enable-frei0r --enable-openal --enable-libopus --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libmp3lame --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libpulse --enable-libsmbclient --enable-libxml2 --enable-librsvg --enable-libdrm --enable-libaom --enable-libdav1d
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
 ... avgblur_opencl    V->V       Apply average blur filter
 ... boxblur_opencl    V->V       Apply boxblur filter to input video
 ... colorkey_opencl   V->V       Turns a certain color into transparency. Operates on RGB colors.
 ... convolution_opencl V->V       Apply convolution mask to input video
 ... deshake_opencl    V->V       Feature-point based video stabilization filter
 ... dilation_opencl   V->V       Apply dilation effect
 ... erosion_opencl    V->V       Apply erosion effect
 ... nlmeans_opencl    V->V       Non-local means denoiser through OpenCL
 ... overlay_opencl    VV->V      Overlay one video on top of another
 ... pad_opencl        V->V       Pad the input video.
 ... prewitt_opencl    V->V       Apply prewitt operator
 ... program_opencl    |->V       Filter video using an OpenCL program
 ... roberts_opencl    V->V       Apply roberts operator
 ... sobel_opencl      V->V       Apply sobel operator
 ... tonemap_opencl    V->V       Perform HDR to SDR conversion with tonemapping.
 ... transpose_opencl  V->V       Transpose input video
 ... unsharp_opencl    V->V       Apply unsharp mask to input video
 ... xfade_opencl      VV->V      Cross fade one video with another video.
 ... openclsrc         |->V       Generate video using an OpenCL program
Many matching lines containing opencl related infos. From the banner line at the top "--enable-opencl" is present too.
Seems opencl support is built in FFmpeg and the system noticed it.
Could you confirm from this output?
Or some other check should be executed to ensure it?
Attached Files
File Type: txt noopencl.diff.txt (2.5 KB, 12 views)

Last edited by joenew; 06-07-2022 at 08:51 AM.
 
Old 06-08-2022, 01:45 PM   #13
joenew
Member
 
Registered: Mar 2010
Distribution: slackware 15.0 64bit
Posts: 190

Original Poster
Rep: Reputation: 23
I have to chnange what I reported above.
No, removing libOpenCL.so from Nvidia installed files isn't enough.
May be I had reinstalled ocl-icd after driver installation. So it worked properly.

But if you have a vanilla slackware and:
- black list nouveau
- install nvidia kernel (patched thanks to AUR diff files)
- install nvidia driver, even with my diff applied to SlackBulid script as I attached in previous message (it will not install libOpenCL.so file)

Then If you attempt to build FFmpeg, it doesn't work and returns the same usual Error as reported at the top of this topic.
Somehow the nvidia driver script overwrites some other ocl-icd file, maybe during post-install when various symlinks are created.

Anyway by reinstalling ocl-icd the issue seems solved, at least partially and allows to build ffmepg without errors.
But this isn't a good way to fix, it would be better to rewrite slackbuilds completely.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] current and nvidia-legacy340-kernel Question re 10-nvidia.conf file MDKDIO Slackware 6 12-16-2020 01:56 PM
[SOLVED] SBo: nvidia-legacy340-kernel: nvidia.ko failed to build lopuh Slackware 3 03-03-2019 12:21 PM
[SOLVED] Slackware: need 14.2 nvidia-legacy340-driver because nouveau.modeset=0 SLOW video 02Victor Slackware 9 12-16-2017 11:42 AM
[SOLVED] nvidia-legacy340-driver (340.96) fabula Slackware 14 02-26-2016 09:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration