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

nvcodec support #34

Closed
wants to merge 10 commits into from
Closed

Conversation

rsnk96
Copy link
Contributor

@rsnk96 rsnk96 commented Oct 19, 2019

Support for nvenc and nvdec for Nvidia GPU-Accelerated encoding and decoding.

Installs only if a valid version of CUDA is detected. Steps follow this guide with the addition of the sed line to ensure that sudo permissions are not needed, and that it is a local copy.

@markus-perl
Copy link
Owner

Hi rsnk96,

Thank you for your contribution.

Normally I don't accept pull requests which require a preinstalled library to work. The basic idea of the script is that all dependencies are resolved automatically, without any user interaction.

But due to the size and hardware dependency of the Nvidia Cuda framework, we may need a different approach.

Possible solutions to include nvcodec in this script could be:

  • Update the projects readme file with a short instruction or a link, what needs to be installed first to compile ffmpeg with nvcodec support
  • Provide a build switch like --with-nvcodec and then download all required dependencies automatically.

Best,
Markus

@rsnk96
Copy link
Contributor Author

rsnk96 commented Oct 21, 2019

I feel the first solution would be better, since having an extra build switch might make the script open to people installing nv-codec without having the dependencies installed. Will update the PR soon

@rsnk96
Copy link
Contributor Author

rsnk96 commented Oct 22, 2019

Better now?

@rsnk96
Copy link
Contributor Author

rsnk96 commented Dec 23, 2019

Hi @markus-perl

Did you get a chance to review this?

@mliradelc
Copy link
Contributor

mliradelc commented Mar 11, 2020

Hi @rsnk96 I just used your PR, first of all great work! I made the same thing but much more static than your approach 😃 .

Besides, I had to make some modifications to make it work:

  • Add the latest change for master (Use C flags and LD flags from the workspace)
  • Update FFmpeg source to the version 4.2.2

Another change I had to make to make it work it was to add a file with the env variables to /etc/profile.d, for example I put the name nvidia.sh

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

It would be great to add a way to detect the version of the Cuda toolkit and the NsightCompute, with that, the Paths could be updated every time.

Here is my repo with the modifications (except the nvidia.sh file)
https://github.com/mliradelc/ffmpeg-build-script/tree/check-install-nvenc

@rsnk96
Copy link
Contributor Author

rsnk96 commented Mar 12, 2020

Hi @mliradelc

That's great! Please feel free to add on to this PR with your updates. Your repo seems to have quite a lot of good modifications and upgrades, perhaps Markus would want to split the upgrades into an independent PR, and have the nvcodec related upgrades in this PR (@markus-perl please let us know your opinion).

On updating the PATH, does Nsight Compute work with nvcodec only if ffmpeg is built while keeping it in its PATH? I have not used NsightCompute before, so just curious :)

@rsnk96
Copy link
Contributor Author

rsnk96 commented Mar 12, 2020

My bad, just saw that the version upgrades was already merged into master. The update looks good, please feel free to merge it into this PR @mliradelc (you could send a PR to https://github.com/detecttechnologies/ffmpeg-build-script/. Once that is merged, this PR to https://github.com/markus-perl/ffmpeg-build-script/ will automatically get updated).

Also, there is one small change you could consider:

Use C flags and LD flags from the workspace

Perhaps the

    --extra-cflags="-I$WORKSPACE/include" \
    --extra-ldflags="-L$WORKSPACE/lib" \
    --extra-cflags="$CFLAGS" \
    --extra-ldflags="$LDFLAGS" \

could be replaced by

    --extra-cflags="-I$WORKSPACE/include $CFLAGS" \
    --extra-ldflags="-L$WORKSPACE/lib $LDFLAGS" \

@mliradelc
Copy link
Contributor

mliradelc commented Mar 13, 2020

Hi @rsnk96

Thank you for your kind words. I made like a year ago some modifications to build FFmpeg with nvenc, and the work of @markus-perl is the best that you can find on the internet over how to compile FFmpeg with almost all the codecs.

On updating the PATH, does Nsight Compute work with nvcodec only if ffmpeg is built while keeping it in its PATH? I have not used NsightCompute before, so just curious :)

Well is true that the NsightCompute is not available when you install the Cuda drivers for FFmpeg. I left that command because it's stated in the installation of the Cuda drivers from Nvidia.

About the change, you suggested to me, I think is a good change and makes the code looks cleaner.

@rsnk96
Copy link
Contributor Author

rsnk96 commented Mar 16, 2020

@mliradelc would you like to add your changes, or should I just update my PR..?

@mliradelc
Copy link
Contributor

@mliradelc would you like to add your changes, or should I just update my PR..?

Hi, I put a PR a few days ago detecttechnologies#1

mliradelc and others added 2 commits March 17, 2020 14:59
- Nvidia codecs list
- Test environments
@rsnk96
Copy link
Contributor Author

rsnk96 commented Mar 18, 2020

Hi, I put a PR a few days ago detecttechnologies#1

Sorry, saw that just now. Merged it!

@markus-perl this is up to date with master now. Two major upgrades are being done:

  • nvenc support
  • Using ffmpeg version tag n4.2.2

@markus-perl
Copy link
Owner

Thanks for the pull request. I will soon have a Linux test system here with an Nvidia graphics card, then I can test the pull request :-)

@markus-perl
Copy link
Owner

Guys, I'm sorry for the delay. I finally merged the pull request into the master branch. I was able to test the script on my ubuntu 20.04 box with an NVIDIA 1070 TI graphics card. Everything worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants