Skip to main content

Using Nvidia GPUs

Ant Media Server can take advantage of a hardware-based encoder found in NVIDIA GPUs. If you have an NVIDIA GPU, you can see if it has a hardware-based encoder in the Video Encode and Decode GPU Support Matrix.

Why use the NVIDIA GPU encoder?

The primary reason is performance. In certain scenarios, encoding performance can improve up to 5 times when compared to CPU-optimized encoders such as x264 or openh264. In the absence of a GPU on the system, Ant Media Server by default uses the openh264 encoder from version 2.5.1 onwards. Prior to that, the x264 encoder was the default choice for AMS.

The utilization of a GPU is advised for demanding transcoding tasks. If you want to publish numerous streams featuring multiple ABRs, using a GPU-optimized server rather than a CPU-optimized one would be a good decision. For instance, a single 4-core CPU-optimized server would struggle to manage a single stream with four ABRs (1080, 720, 480, and 360), and this approach is not recommended. However, a single 4-core GPU-optimized server can effortlessly handle 5–6 streams that have the same ABRs enabled.

Install the CUDA toolkit

Once you have confirmed the existence of a hardware-based encoder in your GPU, the only remaining step is to install the CUDA toolkit onto your system.

Installation on Ubuntu 18.04, 20.04 and 22.04

Ant Media Server now automatically utilizes the GPU with CUDA version 11.8, which is why it is necessary to install it.

To install, follow this link and select the settings according to your operating system and architecture. You can then use the commands provided to complete the installation. Refer to the screenshot below for further guidance.

Instead of using sudo apt-get -y install cuda command to download whole CUDA package, we will just install the limited package of CUDA 11.8 to decrease installation time and space.

Ubuntu 18.04

sudo wget
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install cuda-runtime-11-8

Ubuntu 20.04

sudo wget
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install cuda-runtime-11-8

Ubuntu 22.04

Ant Media Server officially supports Ubuntu 22.04 on versions 2.6 and higher.

sudo wget
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install cuda-runtime-11-8

NVIDIA A10 Tensor Core GPU

If you are using a GPU instance of the NV4as_v4/NV6ads family from Azure Marketplace, which features the NVIDIA A10 Tensor Core GPU, you may need to install the NVIDIA GRID drivers to ensure proper GPU functionality.

sudo wget
sudo chmod +x
sudo ./
sudo reboot

Check the usage of GPU

After installation of CUDA toolkit, you can run the command below to see the status of your GPU.


You can install Ant Media Server using the usual method, or if you have already installed it, you can restart the Ant Media Server.

sudo service antmedia restart

You will see output below if the GPU is in use.

Using NVIDIA hardware based encoder

When using CUDA 11.8, Ant Media Server will verify and record the presence of a hardware-based GPU encoder during startup, and will use it automatically without requiring any additional action.

If you've already installed another CUDA version and it does not work with AMS, you may install compatibility packages.

sudo apt-get install cuda-cudart-11-8
sudo apt-get install cuda-compat-11-8

After installing packages, reboot the server once.

If you need more information for installing on other systems, please check NVIDIA docs and CUDA downloads pages.

Multi-GPU usage

In v2.9.0 and above, hardware scaling property have been added on the server side for smooth streaming operations using GPUs.

By default, hardware scaling is enabled in the application settings. You can find the property under Application's advanced settings.

"hwScalingEnabled": true,

In case, when the system has multiple GPUs, set this property to false so that the load can be distributed between multiple GPUs.

"hwScalingEnabled": false,

Please see the screenshot below for multi-GPU usage with Ant Media Server. In this example, 8 streams were published to the server using 4 ABRs, and as you can see, both GPUs were utilized.