computers:ffmpeg:using_nvenc_cuda

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
computers:ffmpeg:using_nvenc_cuda [2023/02/23 02:13] joncomputers:ffmpeg:using_nvenc_cuda [2023/03/18 03:34] (current) – [Package Requirements] jon
Line 7: Line 7:
 ===== Software requirements ===== ===== Software requirements =====
  
-==== Nvidia Drivers ====+==== Package Requirements ====
  
-Install repo, install driver, reboot+The Nvidia guide ((https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/#compiling-for-linux)) does not work with the limited amount of packages required. I referred to the official ffmpeg compile guide ((https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#FFmpeg)) which gives you the following:
  
-==== Cuda Headers ====+<code> 
 +sudo apt-get update -qq && sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev 
 +</code>
  
-Per NVIDIA,((https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/)) they want you to download the Cuda Headers from VideoLan's Git page. You can't always trust it though, it may be a version off. In my last go-round, they were still on version 11, while my setup was looking for version 12. Either way, download the files from an alternative source (like FFMpeg's Git Repo https://github.com/FFmpeg/nv-codec-headers)and compile as normal.+HonestlyI think just installing pkg-config from the repo will sufficebut this just helps overall to ensure ffmpeg compiles without issues.
  
-==== Packages from repo ====+==== Nvidia Drivers ====
  
-<code>mkdir -p ~/ffmpeg ~/bin+https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Debian&target_version=11&target_type=deb_network
  
-sudo apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev+<code> 
 +wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb 
 +sudo dpkg -i cuda-keyring_1.0-1_all.deb 
 +sudo add-apt-repository contrib 
 +sudo apt-get update 
 +sudo apt-get -y install cuda
 </code> </code>
  
-additional packages+=== Install linux headers ===
  
-<code>apt install nasm libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libopus-dev libdav1d-dev+Per NVIDIA((https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#verify-the-system-has-the-correct-kernel-headers-and-development-packages-installed)), they want you to install headers based on uname -r. Instead, install the package from the base arch level, not specific kernel version. This way when you update, the headers update too. In my case, running Debian, it would be linux-headers-amd64
  
-#libaom, manual compile+==== Cuda Headers ====
  
-cd ~/ffmpeg_sources && \ +Per NVIDIA,((https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/)) they want you to download the Cuda Headers from VideoLan's Git page. You can't always trust it though, it may be a version off. In my last go-round, they were still on version 11, while my setup was looking for version 12Either way, download the files from an alternative source (like FFMpeg's Git Repo https://github.com/FFmpeg/nv-codec-headers), and compile as normal. 
-git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \ + 
-mkdir -p aom_build && \ +==== Showing the driver connections ====
-cd aom_build && \ +
-PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_TESTS=OFF -DENABLE_NASM=on ../aom && \ +
-PATH="$HOME/bin:$PATH" make && \ +
-make install +
-</code>+
  
-==== Driver connection chart ====+First things first, do an ldconfig -v to see if there are any conflicts with the shared libs
  
-<code>ldd /usr/local/bin/ffmpeg+Then run an ldd of the binary you want to check to show all of the dependent shared libs. If any are missing, you will need to check on what was missed in the pre-steps. The NPP libs are part of the cuda toolkit 
 +<code>ldd /usr/local/bin/ffmpeg ##Or wherever you compiled ffmpeg
  linux-vdso.so.1 (0x00007ffd5ed27000)  linux-vdso.so.1 (0x00007ffd5ed27000)
  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f45a5902000)  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f45a5902000)
Line 64: Line 67:
 ===== Install steps =====  ===== Install steps ===== 
  
-==== Download ffmpeg ====+I do prefer using the full guide, as there are additional steps you'll need to get everything set for ffmpeg
  
-<code>cd ~/ffmpeg_sources && git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/</code>+https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions
  
-==== Set Paths ====+==== Download ffmpeg ====
  
-<code> +Grab ffmpeg from its source
-cd ffmpeg/+
  
-PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" +<code>git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/</code>
-</code>+
  
-=== Configure ===+==== Set Paths ====
  
-This is a WIP, hoping to cut this down to the minimal needed for doing any files thru nvenc only +You'll want to check out the full docs ((https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup)) for the env setups.
-<code> +
-./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-cflags=-I/usr/local/cuda/include --extra-ldflags="-L$HOME/ffmpeg_build/lib" --extra-ldflags=-L/usr/local/cuda/lib64 --extra-libs="-lpthread -lm" --ld="g++" --bindir="$HOME/bin" --enable-gpl --enable-libfdk-aac --enable-libopus --enable-libdav1d --enable-libvpx --enable-libx264 --enable-libx265 +
-</code>+
  
-=== Compile ===+<code>export LD_LIBRARY_PATH=/usr/local/cuda-12.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}</code>
  
-Sets the compiled app output to ~/bin +Don't think this is needed.. 
 +<code>PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"</code>
  
-<code>PATH="$HOME/bin:$PATH" make</code>+=== Running the ffmpeg configure script ===
  
-=== Install ===+This is the official way of doing things: 
 +<code>./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared</code>
  
-<code>make install</code>+This is a WIP, hoping to cut this down to the minimal needed for doing any files thru nvenc only.  
 +<code> 
 +./configure --pkg-config-flags="--static" --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-cflags=-I/usr/local/cuda/include --extra-ldflags="-L$HOME/ffmpeg_build/lib" --extra-ldflags=-L/usr/local/cuda/lib64 --extra-libs="-lpthread -lm" --ld="g++" --enable-gpl --enable-libfdk-aac --enable-libopus --enable-libdav1d --enable-libvpx --enable-libx264 --enable-libx265 
 +</code>
  
 ==== Optional - Move files into /usr/ for global use ==== ==== Optional - Move files into /usr/ for global use ====
  
-<code>cp ~/bin/ffmpeg /usr/local/bin/</code>+<code>cp ffmppegdir/ffmpeg /usr/local/bin/</code>
  
 ===== Resources ===== ===== Resources =====
  • computers/ffmpeg/using_nvenc_cuda.1677118426.txt.gz
  • Last modified: 2023/02/23 02:13
  • by jon