# Hardware Encoder Support

OvenMediaEngine Enterprise를 RPM/DEB 패키지 파일로 설치할 경우, 해당 장비에 **NVIDIA 그래픽 카드** 또는 **Xilinx Alveo U30MA** 카드와 드라이버만 설치되어 있으면 Hardware-Accelerated Video Encoding이 자동으로 활성화됩니다. 그래픽 드라이버는 RPM/DEB 패키지 설치 후에도 재설치, 업데이트 및 삭제가 가능하며 프로그램 실행에 영향을 주지 않습니다. 이 문서에서는 지원 버전, 지원 코덱, 드라이버 설치 및 확인 방법에 대해 설명합니다.

## 지원 OS 및 드라이버 버전

| Device             | Support OS                                         | Driver Verion                                  |
| ------------------ | -------------------------------------------------- | ---------------------------------------------- |
| NVIDIA             | <p>Ubuntu 22.04,</p><p>Ubuntu 24.04<br>Rocky 9</p> | <p>NVIDIA Driver 470+<br>CUDA Driver 10.1+</p> |
| Xilinx Alveo U30MA | <p>Ubuntu 22.04,</p><p>Ubuntu 24.04</p>            | Xilinx Video SDK 3.0                           |

## 지원 코덱

<table><thead><tr><th width="246">Device</th><th>Decoder</th><th>Filter</th><th>Encoder</th></tr></thead><tbody><tr><td>NVIDIA</td><td>H.264, H.265</td><td>Scaler</td><td>H.264, H.265</td></tr><tr><td>Xilinx Alveo U30MA</td><td>H.264, H.265</td><td>Scaler</td><td>H.264, H.265</td></tr></tbody></table>

&#x20;

## 드라이버 설치 및 확인 방법

### NVIDIA 그래픽  드라이버&#x20;

이 문서의 내용은 Open-Source로 릴리즈된 OvenMediaEngine에서 제공되는 `misc/install_nvidia_driver.sh` 스크립트를 기반으로 작성되었습니다. 설치가 안 될 경우, NVIDIA [공식 문서](https://docs.nvidia.com/cuda/archive/11.6.0/cuda-installation-guide-linux/#package-manager-installation)를 참고하시기 바랍니다.

#### Ubuntu Linux 22.04 / 24.04

```bash
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends apt-utils lshw
sudo apt-get -y install --no-install-recommends keyboard-configuration
sudo apt-get -y install --no-install-recommends ubuntu-drivers-common
sudo apt-get -y install --no-install-recommends gnupg2 ca-certificates software-properties-common


# Uninstalling a previously installed NVIDIA Driver
sudo apt-get -y remove --purge nvidia-*
sudo apt-get -y autoremove
sudo apt-get -y update

# Remove the nouveau driver.
# If the nouveau driver is in use, the nvidia driver cannot be installed.
USE_NOUVEAU=`sudo lshw -class video | grep nouveau`
if [ ! -z "$USE_NOUVEAU" ]; then

        # Disable nouveau Driver
        echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
        echo "blacklist lbm-nouveau" >> /etc/modprobe.d/blacklist.conf
        echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist.conf
        echo "alias nouveau off" >> /etc/modprobe.d/blacklist.conf
        echo "alias lbm-nouveau off" >> /etc/modprobe.d/blacklist.conf
        sudo update-initramfs -u
        echo "Using a driver display nouveau.Remove the driver and reboot.Reboot and installation script to rerun the nvidia display the driver to complete the installation."

        sleep 5s
        reboot
fi

# Custom Driver Version
NVIDIA_DRIVER_VERSION=

# Install nvidia drivers and cuda-toolit
sudo add-apt-repository -y  ppa:graphics-drivers/ppa

sudo apt -y update
if [ -z "$NVIDIA_DRIVER_VERSION" ]
then 
    # installation with recommended version
    sudo ubuntu-drivers autoinstall
else
    # installation with specific version
    sudo apt-get install -y --no-install-recommends nvidia-driver-${NVIDIA_DRIVER_VERSION}
fi     
sudo apt-get install -y --no-install-recommends nvidia-cuda-toolkit
```

#### Rocky Linux (검증 필요)

```bash
sudo yum -y update
sudo yum -y install kernel-devel
sudo yum -y install epel-release
sudo yum -y install dkms curl lshw
sudo yum -y install subscription-manager

echo "Reboot is required to run with a new version of the kernel."

# Remove the nouveau driver.
USE_NOUVEAU=`lshw -class video | grep nouveau`
if [ ! -z "$USE_NOUVEAU" ]; then

        # Disable nouveau Driver
        sudo sed "s/GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 rd.driver.blacklist=nouveau nouveau.modeset=0\"/" /etc/default/grub
        sudo grub2-mkconfig -o /boot/grub2/grub.cfg
        sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
        sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
        sudo dracut /boot/initramfs-$(uname -r).img $(uname -r)

        echo "Using a driver display nouveau. so, remove the driver and reboot. "
        echo "After reboot and installation script to rerun the nvidia display the driver to complete the installation."

        sleep 5s
        sudo reboot
fi

sudo subscription-manager repos --enable=rhel-7-server-optional-rpms
sudo yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
sudo yum clean expire-cache

sudo yum -y install nvidia-driver-latest-dkms
sudo yum -y install cuda
sudo yum -y install cuda-drivers
```

#### 드라이버 설치 확인

```bash
# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

# nvidia-smi 
Wed Jul  3 23:30:00 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.256.02   Driver Version: 470.256.02   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:0A:00.0 Off |                  N/A |
| 55%   33C    P8    10W / 120W |      2MiB /  3018MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+                                                                  
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
```

### XILINX Video SDK 3.0 드라이버&#x20;

Xilinx Video SDK 3.0 드라이버는 공식적으로 Ubuntu, Red Hat Linux 7.8, 및 Amazon Linux 2를 지원합니다. 자세한 내용은 [Xilinx 공식 문서](https://xilinx.github.io/video-sdk/v3.0/getting_started_on_prem.html#install-the-sdk)를 참고하세요.

## Hardware-Accelerated Video Encoding 활성화 확인 방법

RPM/DEB 패키지와 드라이버 설치가 완료되면, OvenMediaEngine에서 드라이버가 정상적으로 로드되어 Hardware-Accelerated Video Encoding 기능이 활성화되었는지 확인해야 합니다. 이를 확인하기 위해 OvenMediaEngine 의 로그 파일로부터 확인 할 수 있습니다.&#x20;

```bash
$ cd /var/log/ovenmediaengine
$ cat ovenmediaengine.log | grep transcoder_gpu

[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:43   | Trying to check the hardware accelerator
[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:278  | NVIDIA. DeviceId(0), Name(NVIDIA GeForce GTX 1060 3GB), BusId(10), CudaId(0)
[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:48   | Supported NVIDIA Accelerator. Number of devices(1)
[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:62   | No supported Xilinx Media Accelerator
[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:72   | No supported Intel QuickSync Accelerator
[OvenMediaEngine:1234] TAG| transcoder_gpu.cpp:82   | No supported Netint VPU Accelerator
```
