After I set up my streaming server, there are some problems brought by the design. Using CPU to process the streams will consume lots of CPU cycles and if the streaming server have lots of connections, resource to handle them will run low if the machine itself does not have strong CPUs. NVIDIA’s NVENC is a way of offload the transcoding to GPUs that is dedicated to such processing and leaves much more CPU cycles for other purposes. However, installing NVIDIA’s driver is a nightmare, which is why I decided to write it down for future reference.
# Fetch system updates (if it is a fresh install) apt-get install update && apt-get install upgrade # Install required packages for NVIDIA driver installation apt-get install build-essential linux-source linux-headers-3.13.0-68-generic linux linux-image-extra-virtual -y # Get NVIDIA CUDA SDK (this is v7.5, for the latest version please visit NVIDIA's site) wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb # Install CUDA SDK (which includes the NVIDIA graphics driver) apt-get update apt-get install cuda -y # Check whether NVIDIA kernel module is loaded modprobe nvidia # If the above fails, try installing NVIDIA graphics drive seperately (this is drier version 352.63, for the latest one go check NVIDIA's website) wget http://us.download.nvidia.com/XFree86/Linux-x86_64/352.63/NVIDIA-Linux-x86_64-352.63.run chmod +x NVIDIA-Linux-x86_64-352.63.run # Run the installer. Accept the EULA and it will ask you whether to overwrite the previously installed driver, choose continue. The installation here should complete. ./NVIDIA-Linux-x86_64-352.63.run # Check whether NVIDIA kernel module is loaded modprobe nvidia # If all things go well here, this command will show detailed information about your GPU nvidia-smi
Then the below installs NVENC SDK’s header into your system.
# Fetch NVENC SDK wget http://developer.download.nvidia.com/compute/nvenc/v5.0/nvenc_5.0.1_sdk.zip # Uncompress the zip and copy the headers to /usr/local/include/ unzip -q nvenc_5.0.1_sdk.zip mv nvenc_5.0.1_sdk/Samples/common/inc/*.h /usr/local/include/
You can then now compile programs that uses NVIDIA’s NVENC to speed up video processing, including ffmpeg.