how to cross compile ffmpeg with nvidia cuda_sdk and libnpp

Questions that occur when trying to compile FFmpeg.
Post Reply
hydra3333
Posts: 123
Joined: Sun Apr 28, 2013 1:03 pm
Contact:

how to cross compile ffmpeg with nvidia cuda_sdk and libnpp

Post by hydra3333 » Thu Aug 10, 2017 12:20 pm

Newbie alert. Googled an issue but couldn't find a solution. So, I am seeking advice from someone who may already have invented this particular wheel or be able to provide pointers on where to next.

Goal:
To cross compile ffmpeg with nvidia cuda_sdk and libnpp under mingw64 so the final .exe runs under windows 10 x64
eg using something like this on the ffmpeg configure commandline

Code: Select all

--enable-cuda-sdk --enable-filter=scale_cuda --extra-cflags=-I/usr/cuda_8.0.61/cuda/include --extra-ldflags=-L/usr/cuda_8.0.61/cuda/lib/x64 
Issue:
Using a version of rdp's fantastic cross-compile script, which is based on Zeranoe's toolchain, with the above flags it eventually yields this error:

Code: Select all

CC	libavfilter/vf_scale_cuda.o
NVCC	libavfilter/vf_scale_cuda.ptx
ERROR: No supported gcc/g++ host compiler found, but clang-3.8 is available.
       Use 'nvcc -ccbin clang-3.8' to use that instead.
ffbuild/common.mak:95: recipe for target 'libavfilter/vf_scale_cuda.ptx' failed
make: *** [libavfilter/vf_scale_cuda.ptx] Error 1
Any suggestions on where to from here to cross-compile it ?

Roughie Process so far:
1. Install this package under an ubuntu 17.04 VM, to get access to the nvcc compiler. It isn't the latest version, but should still work.
sudo apt-get install -y nvidia-cuda-toolkit
2. This isn't enough, we also *need* the *Windows* libs and includes, so download the relevant cuda toolkit exe under Windows 10
from the nvidia developer site, https://developer.nvidia.com/cuda-downloads

Code: Select all

cuda_8.0.61_win10.exe
3. Then run cuda_8.0.61_win10.exe in Windows 10.
It'll extract the files to a temporary folder before it then tries to install the stuff.
After it's finished extracting and then whilst it's figuring out how to install, copy the full extracted folder tree to another place so we have our own copy if it.
After our own folder copies have finished, cancel the installation.
4. Locate folders cuda/include and cuda/lib/x64 in the newly copied folder tree and copy them to somewhere else alongside one another.
Then also locate folders /npp/include and /npp/lib/x64 and also copy them to somewhere else alongside one another.
5. Back under Linux Ubuntu, use sudo to create folder cuda_8.0.61 under /usr and then set permissions on it sort of like this

Code: Select all

sudo mkdir /usr/cuda_8.0.61
chmod +777 -R /usr/cuda_8.0.61
6. Copy those 4 folder trees we copied earlier, from Windows to the Ubuntu box to become like these

Code: Select all

/usr/cuda_8.0.61/cuda/include
/usr/cuda_8.0.61/cuda/lib/x64 
/usr/cuda_8.0.61/npp/include 
/usr/cuda_8.0.61/npp/lib/x64
7. Now we should be able to type nvcc and see it try to compile something and fail which is OK
By now the necessary folders and whatnot exist (well, nearly) for ffmpeg to be built (cross-compiled) with cuda sdk.
8. Edit the ffmpeg cross-compile build script and add these flags to the ffmpeg configure, to cross-compile stuff with the cuda sdk

Code: Select all

--enable-cuda-sdk --enable-filter=scale_cuda --extra-cflags=-I/usr/cuda_8.0.61/cuda/include --extra-ldflags=-L/usr/cuda_8.0.61/cuda/lib/x64 
9. Then if you're game, also add these flags to the ffmpeg cross-compile configure line

Code: Select all

--enable-libnpp --extra-cflags=-I/usr/cuda_8.0.61/npp/include --extra-ldflags=-L/usr/cuda_8.0.61/npp/lib/x64
10. Try to cross-compile ffmpeg and see how the luck holds. (edit: it blows up, hence this post)



edit: interesting info here. i think i'm stuck
https://bugs.debian.org/cgi-bin/bugrepo ... bug=862522
Last edited by hydra3333 on Thu Aug 10, 2017 1:53 pm, edited 1 time in total.

BiDouiLle
Posts: 42
Joined: Wed Oct 17, 2012 7:45 am
Location: Corsica

Re: how to cross compile ffmpeg with nvidia cuda_sdk and libnpp

Post by BiDouiLle » Thu Aug 10, 2017 12:52 pm

I successfully crosscompiled for x86_64 with both cuda and npp a few months ago by following RDP script.
Ran very well on win10 x64.
I don't even remember which version of what I were using tho but it was under a debian cli only vm :/

hydra3333
Posts: 123
Joined: Sun Apr 28, 2013 1:03 pm
Contact:

Re: how to cross compile ffmpeg with nvidia cuda_sdk and libnpp

Post by hydra3333 » Thu Aug 10, 2017 12:56 pm

OK, yah.
I use rdp's too and it cross-compiles with CUDA (but not cuda_sdk) and then with a few tweaks it also builds with nvidia's OpenCL too.

hydra3333
Posts: 123
Joined: Sun Apr 28, 2013 1:03 pm
Contact:

Re: how to cross compile ffmpeg with nvidia cuda_sdk and libnpp

Post by hydra3333 » Fri Aug 11, 2017 1:01 pm

Ah, this link https://bugs.debian.org/cgi-bin/bugrepo ... bug=862522 seems to have done tests which indicate that cross-compiling ffmpeg with cuda-sdk is well nigh impossible with a variation of rdp's script under gcc 7.1.0.

Oh well, giving up unless someone has done it and is willing to share info.

Post Reply