I am trying to use NVIDIA hardware acceleration with FFmpeg/libav, but can’t get it to work correctly on Azure vm’s running Ubuntu 16.04. For a sample case, I am trying to do a simple decoding of an h264 video into a raw YUV file.
So far, I’ve tried it on NC-6, NC-12, and NV-6 machines (in different regions). In each of these instances, it would take about 30-45 seconds to process a single video frame. As a comparison, I also tried it on a P2.xlarge vm on AWS (which has very similar specs to the NC-6), which was able to process about 3000 frames in about 5 seconds. Has anyone else run into this issue with Azure machines, or has any idea why this would be the case?
Here are the commands I used to install the necessary drivers/libraries/etc (I also verified that each machine as the same NVIDIA driver version installed - 375.51):
CUDA_REPO_PKG=cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
get -O /tmp/${CUDA_REPO_PKG} http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i /tmp/${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get install -y cuda-drivers
sudo apt-get install -y cuda
sudo apt-get install -y nvidia-cuda-toolkit
[reboot]
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
[reboot]
git clone GitHub - FFmpeg/FFmpeg: Mirror of https://git.ffmpeg.org/ffmpeg.git
[download the latest video codec SDK from NVIDIA at: https://developer.nvidia.com/designworks/video_codec_sdk/downloads/v7.1]
[unzipped codec, and copy header files from /Video_Codec_SDK_7.1.9/Samples/common/inc/ into /usr/include/]
cd ~/FFmpeg
./configure --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-Ilocal/include --extra-cflags=-I…/nv_sdk --extra-ldflags=-L…/nv_sdk
sudo make && sudo make install
For the FFmpeg command that I used to decode a sample movie file, I used the following:
sudo ffmpeg -vsync 0 -c:v h264_cuvid -i sample_vid.mp4 -f rawvideo outputvid.yuv