From c2a7be94806a07dfe836e8c122bd3e56d2697ed5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 5 May 2023 12:12:47 -0700 Subject: [PATCH] add nvidia Dockfile --- Dockerfile.nvidia | 17 +++++++++++++++++ build-ffmpeg-nvidia.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Dockerfile.nvidia create mode 100755 build-ffmpeg-nvidia.sh diff --git a/Dockerfile.nvidia b/Dockerfile.nvidia new file mode 100644 index 00000000..e81b5d5b --- /dev/null +++ b/Dockerfile.nvidia @@ -0,0 +1,17 @@ +FROM golang:bullseye AS builder +WORKDIR /app +COPY . . +RUN CGO_ENABLED=0 go build -buildvcs=false -ldflags="-s -w" + +FROM nvidia/cuda:11.1.1-base-ubuntu20.04 +ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=all + +WORKDIR /app +ENV DEBIAN_FRONTEND=noninteractive +COPY ./build-ffmpeg-nvidia.sh . +RUN ./build-ffmpeg-nvidia.sh + +COPY --from=builder /app/go-vod . +EXPOSE 47788 +CMD ["/app/go-vod"] diff --git a/build-ffmpeg-nvidia.sh b/build-ffmpeg-nvidia.sh new file mode 100755 index 00000000..894efe80 --- /dev/null +++ b/build-ffmpeg-nvidia.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +apt-get update +apt-get remove -y libva ffmpeg +apt-get install -y \ + sudo curl wget \ + autoconf libtool libdrm-dev xorg xorg-dev openbox \ + libx11-dev libgl1-mesa-glx libgl1-mesa-dev \ + xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev \ + libxkbcommon-x11-dev libxcb-dri3-dev \ + cmake git nasm build-essential \ + libx264-dev \ + libffmpeg-nvenc-dev clang + +git clone --branch sdk/11.1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git +cd nv-codec-headers +sudo make install +cd .. + +git clone --depth 1 --branch n5.1.3 https://github.com/FFmpeg/FFmpeg +cd FFmpeg +./configure \ + --enable-nonfree \ + --enable-gpl \ + --enable-libx264 \ + --enable-nvenc \ + --enable-ffnvcodec \ + --enable-cuda-llvm + +make -j"$(nproc)" +sudo make install +sudo ldconfig +cd .. + +rm -rf /var/lib/apt/lists/*