Containers

Docker

AMA containerization through Docker does not require any customized steps. All that is required is the inclusion of the SDK packages, during the build step, and inclusion of target devices, during the execution step. The following subsections provide an example for each of these steps.

Docker Build

  1. The following Docker file demonstrates a bare minimum dockerfile:

    FROM ubuntu:22.04
    ARG DEBIAN_FRONTEND="noninteractive"
    SHELL ["/bin/bash", "-c"]
    
    RUN apt -y update \
             && apt -y upgrade \
             && apt-get -y install wget
    
    RUN wget -qO - https://www.xilinx.com/support/download/2018-2-1/xilinx-master-signing-key.asc > /usr/share/keyrings/xilinx-maste
    r-signing-key.asc \
             && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/xilinx-master-signing-key.asc] https://packages.xilinx.com/artif
    actory/debian-packages jammy main" > /etc/apt/sources.list.d/xilinx.list \
             && apt -y update \
             && DEBIAN_FRONTEND=noninteractive apt install -y amd-ama-core=<SDK VERSION>-* amd-ama-xma=<SDK VERSION>-* amd-ama-ffmpeg=<SDK VERSION>-* amd-ama
    -gstreamer=<SDK VERSION>-* \
             && apt-mark hold amd-ama-core amd-ama-xma amd-ama-ffmpeg amd-ama-gstreamer
    
    RUN dpkg --configure -a
    

    , where <SDK VERSION> is the target AMA SDK version. If <SDK VERSION> is omitted, the latest sdk version will be used. It is assumed that the corresponding amd-ama-driver package is already installed on the host system.

  2. A Docker image is then created:

    DOCKER_BUILDKIT=1 docker build --tag=ma35d_sdk --rm .
    

Docker Run

  1. Pass target device(s) to the container, for video processing:

    docker run --device=/dev/ama_transcoder<D>:/dev/ama_transcoder0 \
     -v /sys/class/misc/ama_transcoder<D>:/sys/class/misc/ama_transcoder0:ro \
    --rm -it --name ma35d_sdk_inst  ma35d_sdk:latest \
    bash -c ". /opt/amd/ama/ma35/scripts/setup.sh && ffmpeg -hide_banner -loglevel info -hwaccel ama -hwaccel_device /dev/ama_transcoder0  -re -f lavfi -i testsrc=duration=60:size=1920x1080:rate=60,format=yuv420p -f rawvideo  -vf "hwupload_ama"  -c:v av1_ama -b:v 5M -f mp4 -y /dev/null"
    

    , where <D> is the host device number that is mapped to ama_transcoder0, within the container.