gvisor
gvisor copied to clipboard
ffmpeg with `h264_nvenc` fails to run on gVisor with `-nvproxy`
Description
ffmpeg supports video encoding and decoding using NVIDIA GPUs. Here's an example command:
wget -q -O /neoncat.mp4 https://media.giphy.com/media/sIIhZliB2McAo/giphy.mp4 && \
ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i /neoncat.mp4 -c:a copy -c:v h264_nvenc -b:v 5M /neoncat_out.mp4
Running that command fails on a container started with -nvproxy -nvproxy-docker
with the following ffmpeg error:
...
[AVHWDeviceContext @ 0x55d500277300] cu->cuInit(0) failed -> CUDA_ERROR_OPERATING_SYSTEM: OS call failed or operation not supported on this OS
Device creation failed: -1313558101.
[h264 @ 0x55d500251900] No device available for decoder: device type cuda needed for codec h264.
...
Suggesting that calling cuInit(0)
fails.
The same command succeeds in runc
, encoding video correctly.
We pass NVIDIA_DRIVER_CAPABILITIES=all
to expose the video
capability.
Steps to reproduce
Build OCI image, example:
docker build -t ffmpeg-test -f Dockerfile .
FROM nvidia/cuda:12.2.0-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install wget ffmpeg -y
RUN wget -q -O /neoncat.mp4 https://media.giphy.com/media/sIIhZliB2McAo/giphy.mp4
Then run in system with GPU available.
docker run --rm --runtime=runsc --gpus=all ffmpeg-test ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i /neoncat.mp4 -c:a copy -c:v h264_nvenc -b:v 5M /neoncat_out.mp4
runsc version
runsc version release-20230920.0-21-ge81e0c72a70b
spec: 1.1.0-rc.1