Estou tentando executar ffmpeg com suporte cuda no docker. Este é meu Dockerfile
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \
echo "UTC" > /etc/timezone && \
apt-get update -y && apt-get install -y tzdata && \
dpkg-reconfigure -f noninteractive tzdata
# Install system dependencies and build tools
RUN apt-get update -qq && apt-get -y install \
gcc \
make \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libharfbuzz-dev \
libgnutls28-dev \
libmp3lame-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
meson \
ninja-build \
pkg-config \
texinfo \
wget \
yasm \
zlib1g-dev \
libtool \
libc6 \
libc6-dev \
unzip \
wget \
libnuma1 \
libnuma-dev \
unzip \
awscli \
curl \
nasm \
nvidia-cuda-toolkit \
libnvidia-decode-525-server && \
apt-get clean
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
node -v && npm -v
ENV PATH="/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
# Install nv-codec-headers
RUN mkdir -p ~/ffmpeg_sources ~/bin && \
cd ~/ffmpeg_sources && \
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \
cd nv-codec-headers && \
make install
# Install FFmpeg with CUDA support
RUN mkdir -p ~/ffmpeg_sources ~/bin && \
cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--enable-nonfree \
--enable-cuda \
--enable-cuvid \
--enable-nvdec \
--enable-nvenc \
--enable-cuda-nvcc \
--enable-libnpp \
--enable-libfreetype \
--enable-libharfbuzz \
--enable-libass \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 \
--disable-static \
--enable-shared && \
PATH="$HOME/bin:$PATH" make -j$(nproc) && \
make install && \
hash -r
RUN cd ~ && mkdir input_videos && mkdir output_videos && mkdir assets
ENV CUDA_VISIBLE_DEVICES=0
CMD ["bash"]
Aqui está meu docker-compose.yml
services:
ffmpeg-cuda:
image: ffmpeg-cuda-node
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
volumes:
- /root/input_videos/:/root/input_videos/
- /root/output_videos/:/root/output_videos/
- /root/assets/:/root/assets/
Sempre que executo um comando ffmpeg com cuda recebo este erro
[mjpeg_cuvid @ 0x5df9a07fd880] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps8) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
[mjpeg_cuvid @ 0x5df9a07fd880] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps10) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
[mjpeg_cuvid @ 0x5df9a07fd880] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps12) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
Mas os drivers foram instalados corretamente. nvidia-smi funciona corretamente dentro do contêiner. Por favor, ajude-me a encontrar o que estou esquecendo nisso.