Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building cuda-based filters #83

Closed
hydra3333 opened this issue Feb 21, 2019 · 7 comments

Comments

@hydra3333
Copy link
Contributor

commented Feb 21, 2019

Hello.
ffmpeg-develop recently talks about building cuda-based filters via a different mechanism.
Some of the commentary is lifted into here https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=5&t=6551
The thread is here http://ffmpeg.org/pipermail/ffmpeg-devel/2019-February/240328.html

Any idea how to implement the cross-compilation of these things given the nvidia SDK will apparently no longer be required ("only" nvcc) ?

@DeadSix27

This comment has been minimized.

Copy link
Owner

commented Feb 27, 2019

EDIT: .exe to test: https://share.toji.site/ffmpeg.exe

Works fine on my end.

Make sure to install cuda correctly using this guide:
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

I only tested 1 filter though.. and merely if it even converts/runs ffmpeg:
I used command line examples I found here (as I never used yadif_cuda before):
https://devtalk.nvidia.com/default/topic/1042459/video-codec-sdk/nvdec-in-ffmpeg-cuvid-drops-frames-when-using-deinterlacing-deint-2-/2

And it seems to have worked fine.

 T.. yadif_cuda        V->V       Deinterlace CUDA frames

image

I Tested this on:
image

@DeadSix27

This comment has been minimized.

Copy link
Owner

commented Feb 27, 2019

PS: There's really not much to do other than applying Philip patches and installing CUDA SDK (and adding that to path according to the guide I linked you, I could do this in the .py but I think this should be done on the users end preferably)

@hydra3333

This comment has been minimized.

Copy link
Contributor Author

commented Feb 28, 2019

Thanks ! Will give it a try too !

edit: I assume nothing additional to be installed in the windows PC to make the cross-compiled ffmpeg.exe run OK ?

@DeadSix27

This comment has been minimized.

Copy link
Owner

commented Feb 28, 2019

@hydra3333 Nothing on the windows pc is required.. other than nVidia driver and GPU I guess.

Also, I think they already began implementing it https://github.com/FFmpeg/FFmpeg/commit/114ead9735f226e5824a15b94b32344436c96a71#diff-e2d5a00791bce9a01f99bc6fd613a39d

So the patches will fail

@hydra3333

This comment has been minimized.

Copy link
Contributor Author

commented Mar 1, 2019

OK, yes, https://git.videolan.org/?p=ffmpeg.git;a=shortlog seems to show the patches committed.
Thanks.

So, next is for me to try this too like you said,

Make sure to install cuda correctly using this guide:
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

and

PS: ... and installing CUDA SDK (and adding that to path according to the guide I linked you, I could do this in the .py but I think this should be done on the users end preferably)

outside the .py

I've been building with ubuntu 18.04 but am considering trying 18.10 to see what happens :)

edit: the nvidia cuda SDK install guide seems to talk about also installing an nvidia driver, which is problematic since I build inside a VM ... oh well, will omit that bit and see what happens

@DeadSix27

This comment has been minimized.

Copy link
Owner

commented Mar 1, 2019

I build inside a VM too. Just download this .run file:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1810&target_type=runfilelocal

either for 18.10 or 04 then run it and just keep all default options selected.

Then add the paths to.. the path (as seen here): https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

You don't need a nVidia GPU for this and it also works in a VM.

@hydra3333

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2019

OK, just for completeness and when I forget for next time, notes consolidated from the nvidia install document:

CUDA SDK Toolkit 10.1 Install Commentary #83 (comment)

CUDA SDK Toolkit 10.1 Download and Install Guideline https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

CUDA SDK Toolkit 10.1 Local Runtime Download page for ubuntu

Source Page
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal
eg for ubuntu 18.04 points to
https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
eg for ubuntu 18.10 points to
https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run

CUDA SDK Toolkit 10.1 Local Runtime Installation

Install the TOOLKIT and SAMPLES like: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile

sudo sh ./cuda_10.1.105_418.39_linux-ubuntu-18.04.run --verbose --toolkit --samples

CUDA SDK Toolkit 10.1 - SETUP PATHS READY FOR CROSS-COMPILING

The PATH variable needs to include
/usr/local/cuda-10.1/bin and /usr/local/cuda-10.1/NsightCompute-.
refers to the version of Nsight Compute that ships with the CUDA toolkit, e.g. 2019.1.

To add this path to the PATH variable:
export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
In addition, when using the runfile installation method, the LD_LIBRARY_PATH variable needs to contain /usr/local/cuda-10.1/lib64 on a 64-bit system, or /usr/local/cuda-10.1/lib on a 32-bit system
To change the environment variables for 64-bit operating systems:
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}

Hence for CUDA SDK Toolkit 10.1 64bit :-

export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}

CUDA SDK Toolkit 10.1 - UNINSTALL NOTES

To uninstall the CUDA Toolkit, run the uninstallation script provided in the bin directory of the toolkit.
By default, it is located in /usr/local/cuda-10.1/bin:

sudo /usr/local/cuda-10.1/bin/cuda-uninstaller

@hydra3333 hydra3333 closed this Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.